react-native-url-receiver

0.0.10 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i react-native-url-receiver

Homepage

appmeup.co

Weekly Downloads

2

Version

0.0.10

License

MIT

Last publish

Collaborators

  • hans-appmeup