updated docs with iOS 10 compatible linking code

Summary:
Thanks for submitting a PR! Please read these instructions carefully:

- [x] Explain the **motivation** for making this change.
- [x] Provide a **test plan** demonstrating that the code is solid.
- [x] Match the **code formatting** of the rest of the codebase.
- [x] Target the `master` branch, NOT a "stable" branch.

The current code for IOS contains deprecated code for incoming urls.
in iOS 10 deprecated openURL.
more details here: https://useyourloaf.com/blog/openurl-deprecated-in-ios10/

1. Create an RN app with iOS 10. set up linking as per instructions.

2. Using the iOS9 code snippet, with the app is open, navigate to the apps url scheme (in safari)  appname://value1/value2, the eventListener will not trigger.  note: it will however trigger getInitialURL if app is closed.

3. Replace the old iOS9 code with the iOS 10 and trigger an incoming url from a browser appname://
with the new code in the doc it will trigger for both open and closed apps.
Closes https://github.com/facebook/react-native/pull/13942

Differential Revision: D5071851

Pulled By: hramos

fbshipit-source-id: 8394de73014a1d2a5982b22b1b6fd09e0cf524dd
This commit is contained in:
Johan 2017-05-16 17:51:20 -07:00 committed by Facebook Github Bot
parent 23e81f2ae3
commit af949877e6
1 changed files with 28 additions and 6 deletions

View File

@ -66,22 +66,44 @@ const LinkingManager = Platform.OS === 'android' ?
* android:launchMode="singleTask">
* ```
*
* NOTE: On iOS you'll need to link `RCTLinking` to your project by following
* NOTE: On iOS, you'll need to link `RCTLinking` to your project by following
* the steps described [here](docs/linking-libraries-ios.html#manual-linking).
* In case you also want to listen to incoming app links during your app's
* execution you'll need to add the following lines to your `*AppDelegate.m`:
* If you also want to listen to incoming app links during your app's
* execution, you'll need to add the following lines to your `*AppDelegate.m`:
*
* ```
* // iOS 10
* #import <React/RCTLinkingManager.h>
* - (BOOL)application:(UIApplication *)application
* openURL:(NSURL *)url
* options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
* {
*
* return [RCTLinkingManager application:application openURL:url
* sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
* annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
*
* }
* ```
*
* If you're targeting iOS 9 or older, you can use the following code instead:
*
* ```
* // iOS 9 or older
* #import <React/RCTLinkingManager.h>
*
* - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
* sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
* {
* return [RCTLinkingManager application:application openURL:url
* sourceApplication:sourceApplication annotation:annotation];
* sourceApplication:sourceApplication annotation:annotation];
* }
*
* // Only if your app is using [Universal Links](https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html).
* ```
*
* If your app is using [Universal Links](https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html),
* you'll need to add the following code as well:
*
* ```
* - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
* restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
* {