revtel / react-native-nfc-manager

React Native NFC module for Android & iOS
MIT License
1.35k stars 317 forks source link

Background NFC opens duplicate react native app on Android #626

Closed abdullahkhalil2 closed 1 year ago

abdullahkhalil2 commented 1 year ago

I am using react native nfc manager. When I scan nfc in the background, my app is opened and nfc is handled but I can see in the multitasking that two apps have opened, when with the nfc native handler icon and the other with my app handler. Because of this behavior of the app is weird. Mutiple success popups would appear and multiple navigation would occur. Seems like changing something on one app triggers action on the other app. below is the android manifest I use to open background tags. On IOS the flow is working perfect. For reference we are using the NFC NTAG216, and I have already enabled forgroundEnable mode in the nodemodules nfcManager.java. Also the behaviour is only odd when the app is in the background when scanning tag. ` <activity android:name="com.holguinmedia.contactapp.MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:exported="true" android:label="@string/app_name" android:launchMode="singleTop" android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize">

        <intent-filter>
            <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:scheme="https"
                android:host="nfc-frontend-testing.crunchyapps.com" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:scheme="https"
                android:host="nfc-frontend-testing.crunchyapps.com/nfc/*" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.nfc.action.TECH_DISCOVERED"/>
        </intent-filter>
        <meta-data android:name="android.nfc.action.TECH_DISCOVERED"
            android:resource="@xml/nfc_filter" />

    <intent-filter>
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="com.holguinmedia.contactapp"
              android:host="*" />
    </intent-filter>
    <intent-filter>
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="com.holguinmedia.contactapp"
              android:host="*" />
    </intent-filter>`

IMG_20230418_125541_402 In the photo as it can be seen, the left app is our app and the right app is the system native app handler.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.

ailtonaires commented 4 months ago

any solution?

abdullahkhalil2 commented 4 months ago

Hi @ailtonaires as far as I remeber I think I added the following line in the manifest file which fixed the issue. android:launchMode="singleTask"