Version.m 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #import "Version.h"
  2. @implementation VersionPlugin
  3. + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
  4. FlutterMethodChannel* channel = [FlutterMethodChannel
  5. methodChannelWithName:@"version"
  6. binaryMessenger:[registrar messenger]];
  7. VersionPlugin* instance = [[VersionPlugin alloc] init];
  8. [registrar addMethodCallDelegate:instance channel:channel];
  9. }
  10. - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
  11. if ([@"jumpAppStore" isEqualToString:call.method]) {
  12. NSURL *url = [NSURL URLWithString:@"itms-apps://itunes.apple.com/app/id1112069772"];
  13. if (@available(iOS 10.0, *)){
  14. [[UIApplication sharedApplication]openURL:url options:@{UIApplicationOpenURLOptionsSourceApplicationKey:@YES} completionHandler:^(BOOL success) {
  15. if (success) {
  16. NSLog(@"10以后可以跳转url");
  17. }else{
  18. NSLog(@"10以后不可以跳转url");
  19. }
  20. }];
  21. }else{
  22. BOOL success = [[UIApplication sharedApplication]openURL:url];
  23. if (success) {
  24. NSLog(@"10以前可以跳转url");
  25. }else{
  26. NSLog(@"10以前不可以跳转url");
  27. }
  28. }
  29. } else {
  30. result(FlutterMethodNotImplemented);
  31. }
  32. }
  33. @end