You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2020/03/04 08:52:40 UTC

[GitHub] [cordova-ios] zhangjingle commented on issue #599: Custom url scheme redirect does not work with cordova platform ios @5.0.0

zhangjingle commented on issue #599: Custom url scheme redirect does not work with cordova platform ios @5.0.0
URL: https://github.com/apache/cordova-ios/issues/599#issuecomment-594398637
 
 
   cordova-ios, CDVAppDelegate.m post openurl notifiycaiton before observer(CDVHandleOpenURL.m) register notification
   
   fix:
   in AppDelegate.m
   #import "AppDelegate.h"
   #import "MainViewController.h"
   
   @interface AppDelegate()
   @property (nonatomic) BOOL pageDidLoad;
   @property (nonatomic, strong) NSURL * openURL;
   @end
   
   @implementation AppDelegate
   
   - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
       // ... your code
       [self fixOpenURL];
       return YES;
   }
   
   -(void)fixOpenURL {
       [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationPageDidLoad:) name:CDVPageDidLoadNotification object:nil];
   }
   
   -(void)applicationPageDidLoad:(NSNotification*)notification {
       self.pageDidLoad = YES;
       [self postMessageForOpenURL];
   }
   
   - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
       self.openURL = url;
       [self postMessageForOpenURL];
       return YES;
   }
   
   -(void)postMessageForOpenURL {
       if (self.openURL && self.pageDidLoad) {
           [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:self.openURL]];
       }
   }
   
   @end
   
   
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org