react-native-url-receiver
v0.0.10
Published
A React Native library for receiving a file URL on iOS
Readme
react-native-url-receiver
A React Native library for receiving a File URL when the app is opened/resumed on iOS
Installation
1. Install the package
npm install react-native-url-receiver
2. Add the following code to your AppDelegate.m
- (BOOL) application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
NSURL *openUrl = url;
if (!openUrl)
{
return NO;
}
[RNReactNativeUrlReceiver setFileURL:[openUrl absoluteString]];
return YES;
}Usage
In your React Native project:
Import the package
import UrlReceiver from 'react-native-url-receiver'
Retrieve the file URL on your component
componentWillMount() {
// Listen for file URL change events
UrlReceiver.addEventListener((fileUrl) => {
if (fileUrl !== null) {
// Here is the file URL
}
})
}
componentWillUnmount() {
// Stop listening to file URL change events
UrlReceiver.removeEventListener()
}License
MIT
