- Add cordova plugin meteor add cordova:cordova-plugin-customurlscheme@4.1.3
- Add config on mobile-config.js App.configurePlugin('cordova-plugin-customurlscheme', { URL_SCHEME: '<name_of_scheme (ex: openapp => openapp://link/to/path)>' });
- Add handle open url function on js window.handleOpenURL = function handleOpenURL(receiveUrl) { setTimeout(function() { let url = receiveUrl; if (typeof window._saveOpenURL != "undefined") { url = window._saveOpenURL; } // handle url here..... }, 0); };
- Build on IOS fix cold start app not run handleOpenURL
References:
https://github.com/EddyVerbruggen/Custom-URL-scheme/issues/154
https://github.com/EddyVerbruggen/Custom-URL-scheme/issues/2#issuecomment-152557017
in Xcode on CDVHanleOpenURL.m comment line self.url = nil on (void)applicationPageDidLoad:(NSNotification*)notification ``` - (void)applicationPageDidLoad:(NSNotification*)notification { // cold-start handler
self.pageLoaded = YES;
if (self.url) {
[self processOpenUrl:self.url pageLoaded:YES];
// self.url = nil; <==== this line
}
}
```
Changed
```
NSString* jsString = [NSString stringWithFormat:@"document.addEventListener('deviceready',function(){if (typeof handleOpenURL === 'function') { handleOpenURL(\"%@\");}});", url];
```
to
```
NSString* jsString = [NSString stringWithFormat:@"if (typeof handleOpenURL === 'function') { handleOpenURL(\"%@\");} else { window._savedOpenURL = \"%@\"; }", url, url];
```