Listening For Incoming Links On Android With React-native
I am able to listen and handle incoming links on IOS with react-native using the linking library: https://facebook.github.io/react-native/docs/linking.html, but it shows the functi
Solution 1:
I just got it working! You just have to follow these instructions.
Basically, add an <intent-filter>
under the existing one of your android/app/src/main/AndroidManifest.xml
, containing the VIEW
action, the DEFAULT
and BROWSABLE
categories, and at least a <data>
.
Then simply rebuild and reinstall your APK (react-native run-android
), that's it! Links matching your <data>
tags will now open in your app!
Now just catch this URL with Linking.getInitialURL() in the componentDidMount()
of your main Javascript class!
Example of manifest:
<manifestxmlns:android="http://schemas.android.com/apk/res/android"package="net.yourapp"android:versionCode="1"android:versionName="0.1"><uses-permissionandroid:name="android.permission.INTERNET" /><uses-permissionandroid:name="android.permission.SYSTEM_ALERT_WINDOW"/><uses-sdkandroid:minSdkVersion="16"android:targetSdkVersion="22" /><applicationandroid:name=".MainApplication"android:allowBackup="true"android:label="@string/app_name"android:largeHeap="true"android:icon="@mipmap/ic_launcher"android:theme="@style/AppTheme"><activityandroid:name=".MainActivity"android:label="@string/app_name"android:screenOrientation="portrait"android:configChanges="keyboard|keyboardHidden|screenSize"><intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter><!-- HERE: --><intent-filter><actionandroid:name="android.intent.action.VIEW" /><categoryandroid:name="android.intent.category.DEFAULT" /><categoryandroid:name="android.intent.category.BROWSABLE" /><dataandroid:scheme="https"android:host="yoursite.net" /><dataandroid:scheme="https"android:host="yoursite.com" /><dataandroid:scheme="https"android:host="yoursite" /><dataandroid:scheme="customscheme"android:host="yourpath" /></intent-filter></activity><activityandroid:name="com.facebook.react.devsupport.DevSettingsActivity" /></application></manifest>
Post a Comment for "Listening For Incoming Links On Android With React-native"