123456789101112131415161718192021222324252627282930313233343536373839 |
- #import "Version.h"
- @implementation VersionPlugin
- + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
- FlutterMethodChannel* channel = [FlutterMethodChannel
- methodChannelWithName:@"version"
- binaryMessenger:[registrar messenger]];
- VersionPlugin* instance = [[VersionPlugin alloc] init];
-
- [registrar addMethodCallDelegate:instance channel:channel];
-
- }
- - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
- if ([@"jumpAppStore" isEqualToString:call.method]) {
- NSURL *url = [NSURL URLWithString:@"itms-apps://itunes.apple.com/app/id1112069772"];
- if (@available(iOS 10.0, *)){
- [[UIApplication sharedApplication]openURL:url options:@{UIApplicationOpenURLOptionsSourceApplicationKey:@YES} completionHandler:^(BOOL success) {
- if (success) {
- NSLog(@"10以后可以跳转url");
- }else{
- NSLog(@"10以后不可以跳转url");
- }
- }];
- }else{
- BOOL success = [[UIApplication sharedApplication]openURL:url];
- if (success) {
- NSLog(@"10以前可以跳转url");
- }else{
- NSLog(@"10以前不可以跳转url");
- }
- }
-
- } else {
- result(FlutterMethodNotImplemented);
- }
- }
- @end
|