don/phonegap-nfc-reader

app doesn't start when scanning a tag

Closed this issue · 5 comments

After scanning a tag, the demo app is not on the list of the available applications to launch.
Phone info: LG Optimus L5 E610, Android 4.0.3, Cordova 2.6

don commented

The demo app will only launch when a MIME Media NFC tag is scanned with a type of "text/pg"

Launching of the application is controlled in the Android Manifest.
https://github.com/don/phonegap-nfc-reader/blob/master/android/AndroidManifest.xml#L27

You can adjust the intent if you'd like to have the application launch with other tags. See Filtering for NFC Intents

Once the NFC reader application is running, tags are handled by the foreground dispatch system which gets priority over intents defined in this and other applications manifests.

Does the MIME type need to be specified in AndroidManifest.xml? (I have a clean tag, and I'm only interested in tag's UID) I also tried to modify AndroidManifest.xml and index.js to catch all tags with no success.

<intent-filter>
                <action android:name="android.nfc.action.TAG_DISCOVERED"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
 </intent-filter>
deviceready: function () {
        function failure(reason) {
            ready = false;
        }

        function success() {
            ready = true;
        }

        nfc.addTagDiscoveredListener(scan.onNfc, success, failure);
    },
don commented

You do not need a MIME type in the manifest unless you want to open the app when scanning a MIME media tag.

There are 2 processes here; when the app is in control and when the OS is in control.

When the application is open, it uses foreground dispatching, which is greedy and reads all tags.

The information in the manifest is strictly for the Android OS to open the application if it is not running (or in the foreground) when a tag is scanned. Usually TAG_DISCOVERED should match everything. You might need something more specific like TECH_DISCOVERED if another app is opening instead of yours.

Hi Don,

I downloaded your zip and sent it to remote phonegap build. I was able to see the green screen on Phonegap reader demo on Android, Samsung S4. However I was not able to see "Scan a tag to being." I thought I should at least see this before the app is awaiting for the card.

Of course, scanning a card didn't work either. Do you know what could be the cause? Need a scanner to work desperately and hope you could advice.

Thanks.

don commented

@jhong1 It sounds like there is a problem initializing the app or the plugin is not installed. Plugins are added to PhoneGap Build projects differently, so you'd need to edit the manifest to get it to work.

If you can attach the phone to your computer and run "adb logcat" you'll get a log file with more information about the problem. If you can't run adb logcat, send me the apk file you generated from phonegap build via email to don at chariot solutions dot com