zhangjingle edited a comment 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: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
