From 8d8c3d4e1eb88366074e87385c4d96a46dfdd544 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Wed, 25 Sep 2019 18:42:47 -0700 Subject: [PATCH] Also listen to NFC actions for linking url events (#26553) Summary: This PR solves bug https://github.com/facebook/react-native/issues/26552 for Android. Allows an app to receive url events through Linking from NFC tags ## Changelog [Android] [Fixed] - This branch checks also for `ACTION_NDEF_DISCOVERED` intent matches to send the url events Pull Request resolved: https://github.com/facebook/react-native/pull/26553 Test Plan: Tested the code multiple times with both NFC tags and normal links Differential Revision: D17589654 Pulled By: cpojer fbshipit-source-id: 55e854e765a84da5e22ec2cc51d0fe0972254175 --- .../main/java/com/facebook/react/ReactInstanceManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 4be00d52779..f6842435cee 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -36,6 +36,7 @@ import android.content.Context; import android.content.Intent; import android.content.res.Configuration; import android.net.Uri; +import android.nfc.NfcAdapter; import android.os.Bundle; import android.os.Process; import android.util.Log; @@ -462,7 +463,9 @@ public class ReactInstanceManager { 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))) { DeviceEventManagerModule deviceEventManagerModule = currentContext.getNativeModule(DeviceEventManagerModule.class); deviceEventManagerModule.emitNewIntentReceived(uri);