Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Libraries/LinkingIOS/RCTLinkingManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@ - (void)setBridge:(RCTBridge *)bridge

- (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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the key defined in UIKit for this instead of the string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, UIApplicationLaunchOptionsUserActivityKey is not documented in Apple API docs and constant UIApplicationLaunchOptionsUserActivityKey is not being exported. The following URL is Apple API doc for launchOptions keys.

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/index.html?hl=ar#//apple_ref/doc/constant_group/Launch_Options_Keys

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, I was looking for a different key

}
}

return @{@"initialURL": RCTNullIfNil(initialURL.absoluteString)};
}

Expand Down