Closed
Description
🐛 Bug Report
I'm trying to use a NFC tag to open a give URL with my application, but Linking.getInitialUrl returns always a null url. However the system recognises the intent registered (so I get asked if I want to open the URL with my app)
To Reproduce
- Create a new app
- Add the following to your AndroidManifest.json:
<uses-permission android:name="android.permission.NFC" />
...
<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:scheme="https" android:host="www.example.com" android:pathPrefix="/some-path/" />
<data android:scheme="https" android:host="example.com" android:pathPrefix="/some-path/" />
<data android:scheme="http" android:host="www.example.com" android:pathPrefix="/some-path/" />
<data android:scheme="http" android:host="example.com" android:pathPrefix="/some-path/" />
<data android:scheme="app" android:host="example" android:pathPrefix="/some-path/" />
<data android:scheme="app" android:host="com.example" android:pathPrefix="/some-path/" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="www.example.com" android:pathPrefix="/some-path/" />
<data android:scheme="https" android:host="example.com" android:pathPrefix="/some-path/" />
<data android:scheme="http" android:host="www.example.com" android:pathPrefix="/some-path/" />
<data android:scheme="http" android:host="example.com" android:pathPrefix="/some-path/" />
</intent-filter>
- create NFC tag with
http://example.com/some-path/this-is-an-url
- Add this to your App.js
public componentDidMount (): void {
Linking.getInitialURL().then(url => {
console.warn('getInitialURL', url)
})
}
-
Read the NFC tag with the mobile NFC reader
-
You get asked if you want to open the URL with the app
-
Click your app
The console.warn prints null
Expected Behavior
Linking.getInitialUrl should return the url found in the NFC tag
The Linking.addEventListener('url', ({url}) => console.warn('event url': url))
should also work
Environment
React Native Environment Info:
System:
OS: Linux 4.18 Ubuntu 18.10 (Cosmic Cuttlefish)
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 145.54 MB / 15.54 GB
Shell: 5.5.1 - /usr/bin/zsh
Binaries:
Node: 10.14.1 - ~/.nvm/versions/node/v10.14.1/bin/node
Yarn: 1.12.3 - ~/.nvm/versions/node/v10.14.1/bin/yarn
npm: 6.5.0 - ~/.nvm/versions/node/v10.14.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
Android SDK:
API Levels: 23, 25, 27, 28
Build Tools: 23.0.1, 23.0.2, 26.0.1, 26.0.2, 27.0.3, 28.0.3
System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom
npmPackages:
react: ^16.8.6 => 16.8.6
react-native: ^0.59.4 => 0.59.4
npmGlobalPackages:
react-native-cli: 2.0.1