add Universal Links support to Linking.getInitialURL(). Fixes #6099
Summary:Currently, Linking.getInitialURL() only supports custom URL scheme and not Universal Links. This PR fixes that. see #6099 Closes https://github.com/facebook/react-native/pull/6147 Differential Revision: D2976902 Pulled By: javache fb-gh-sync-id: 750fe4a7c251ba57433c3a24866a4a510f125069 shipit-source-id: 750fe4a7c251ba57433c3a24866a4a510f125069
This commit is contained in:
parent
3ed66ee7b5
commit
f0689cf534
|
@ -33,7 +33,18 @@ RCT_EXPORT_MODULE()
|
|||
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
NSURL *initialURL = _bridge.launchOptions[UIApplicationLaunchOptionsURLKey];
|
||||
NSURL *initialURL;
|
||||
|
||||
if (_bridge.launchOptions[UIApplicationLaunchOptionsURLKey]) {
|
||||
initialURL = _bridge.launchOptions[UIApplicationLaunchOptionsURLKey];
|
||||
} else if (_bridge.launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey]) {
|
||||
NSDictionary *userActivityDictionary = _bridge.launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey];
|
||||
|
||||
if ([userActivityDictionary[UIApplicationLaunchOptionsUserActivityTypeKey] isEqual:NSUserActivityTypeBrowsingWeb]) {
|
||||
initialURL = ((NSUserActivity *)userActivityDictionary[@"UIApplicationLaunchOptionsUserActivityKey"]).webpageURL;
|
||||
}
|
||||
}
|
||||
|
||||
return @{@"initialURL": RCTNullIfNil(initialURL.absoluteString)};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue