Skip to content

[Linking] add Universal Links support to Linking.getInitialURL(). Fixes #6099 #6147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

daesan
Copy link
Contributor

@daesan daesan commented Feb 25, 2016

Currently, Linking.getInitialURL() only supports custom URL scheme and not Universal Links. This PR fixes that. see #6099

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @nicklockwood, @tadeuzagallo and @deminoth to be potential reviewers.

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks!

@satya164 satya164 changed the title [Linking] add Universal Links support to Linking.getInitialURL() [Linking] add Universal Links support to Linking.getInitialURL(). Fixes #6099 Feb 25, 2016
@satya164
Copy link
Contributor

cc @javache @nicklockwood

@satya164 satya164 added the Platform: iOS iOS applications. label Feb 25, 2016
} else if (_bridge.launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey]) {
NSDictionary * userActivityDictionary = _bridge.launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey];

if ([(NSString *)userActivityDictionary[UIApplicationLaunchOptionsUserActivityTypeKey] isEqualToString:NSUserActivityTypeBrowsingWeb]) {
Copy link
Member

Choose a reason for hiding this comment

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

No need to cast, just use isEqual

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 25, 2016
@facebook-github-bot
Copy link
Contributor

@daesan updated the pull request.

} else if (_bridge.launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey]) {
NSDictionary *userActivityDictionary = _bridge.launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey];

if ([userActivityDictionary[UIApplicationLaunchOptionsUserActivityTypeKey] isEqualToString:NSUserActivityTypeBrowsingWeb]) {
Copy link
Member

Choose a reason for hiding this comment

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

Use isEqual:, which is defined on NSObject. If the object you get there is not a string, isEqualToString: will crash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got you.

@facebook-github-bot
Copy link
Contributor

@daesan updated the pull request.

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

@javache
Copy link
Member

javache commented Feb 25, 2016

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to Phabricator to review.

@ghost ghost closed this in f0689cf Feb 25, 2016
@daesan daesan deleted the universal-links branch February 25, 2016 15:44
pglotov pushed a commit to pglotov/react-native that referenced this pull request Mar 15, 2016
…k#6099

Summary:Currently, Linking.getInitialURL() only supports custom URL scheme and not Universal Links. This PR fixes that. see facebook#6099
Closes facebook#6147

Differential Revision: D2976902

Pulled By: javache

fb-gh-sync-id: 750fe4a7c251ba57433c3a24866a4a510f125069
shipit-source-id: 750fe4a7c251ba57433c3a24866a4a510f125069
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants