Reputation: 799
I want my React Native app to be able to receive URL intents from another apps. So for instance, when I scan a URL with a QR code scanner and want to open it, among my installed browsers will also appear my React Native app.
I followed the instructions of Linking:
componentDidMount()
as shown in the Linking documentation.In android/app/src/main/AndroidManifest.xml
, I edited the <intent filter>
section according to the Android docs, so that it looks now like this:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/gizmos" />
</intent-filter>
Having done this, I expected that after scanning a http://www.example.com/gizmos
with my QR scanner and trying to open it, the scanner would offer me also my React Native app. However, it does only show my previously installed browsers.
Is my expectation wrong? Or can do something to make this happen?
Upvotes: 1
Views: 1430
Reputation: 26387
It's not enough to catch the action android:name="android.intent.action.MAIN"
but you need to catch android:name="android.intent.action.VIEW"
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="www.example.com" android:scheme="http" />
</intent-filter>
Upvotes: 1