chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
706 stars 557 forks source link

Cannot launch app on Android when scanning a tag #255

Closed bastos71 closed 7 years ago

bastos71 commented 7 years ago

Hi everyone !

I'm trying to automaticaly launch my app when scanning a NFC tag. I don't understand why but it fails :/

I saw on Readme.md I have to add thos lines in my /platforms/android/AndroidManifest.xml :

<intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED" /> <data android:mimeType="text/pg" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter>

Could someone give me a config.xml file example to understand my mistake ?

Thanks !

don commented 7 years ago

You need to add the intent filter into AndroidManifest.xml not config.xml

Change android:mimeType from text/pg to match the mime type of your tag. You can also add different intent filters based on the tag content. See https://developer.android.com/guide/topics/connectivity/nfc/nfc.html#ndef-disc

Note that you need ndef.addMimeTypeListener in your app to handle the tag that is scanned to launch the app.

don commented 7 years ago

@bastos71 this after_prepare hook works well for adding an intent to the AndroidManifest.xml http://stackoverflow.com/a/35597489/1416463

bastos71 commented 7 years ago

Thank you for your help @don , I will take a look as soon as possible.