From 54abe1f5990b8f5f57da3231d1bb1fd83966f064 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Tue, 28 May 2019 07:30:00 -0700 Subject: [PATCH] Linking.getInitialURL() to work with NFC tags on Android (#25055) Summary: This PR solves bug https://github.com/facebook/react-native/issues/24393 for Android. Allows an app to be opened with an NFC tag and getting the url trough Linking.getInitialURL() ## Changelog [Android] [Fixed] - This branch checks also for `ACTION_NDEF_DISCOVERED` intent matches to set the initialURL Pull Request resolved: https://github.com/facebook/react-native/pull/25055 Differential Revision: D15516873 Pulled By: cpojer fbshipit-source-id: e8803738d857a69e1063e926fc3858a416a0b25e --- .../java/com/facebook/react/modules/intent/IntentModule.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java index 50c6d40580..9cf2a7e947 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java @@ -12,6 +12,7 @@ import android.content.ComponentName; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; +import android.nfc.NfcAdapter; import android.provider.Settings; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; @@ -59,7 +60,7 @@ public class IntentModule extends ReactContextBaseJavaModule { String action = intent.getAction(); Uri uri = intent.getData(); - if (Intent.ACTION_VIEW.equals(action) && uri != null) { + if (uri != null && (Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action))) { initialURL = uri.toString(); } }