Add URL change notification description to README

This commit is contained in:
Andy
2017-02-09 01:50:04 +00:00
committed by GitHub
parent 3f3cb2086e
commit 164bf64cbd

View File

@@ -43,6 +43,15 @@ SafariView.show({
});
```
### URL Change Notifications
There isn't an API for retrieving URL changes provided by SFSafariViewController or its delegate in iOS, so there's no way to know where the user is navigating to. However, it is possible to get a notification when the Safari View navigates to an URL scheme specified by your app (e.g. `your-app-name://`). This is especially useful for implementing callback oriented flows such as in OAuth2 / OpenID Connect.
To get URL notifications for your URL scheme you'll need to:
1. Register an [URL scheme](https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html#//apple_ref/doc/uid/TP40007072-CH6-SW10) in your Xcode Project
2. Make sure you've set up [Linking](https://facebook.github.io/react-native/docs/linking.html) in your react-native project.
3. Listen for URL changes in your react-native code (i.e. `Linking.addEventListener('url', eventHandler)`);
## Example
Using Safari View in your app will usually look like this:
```js