Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 12 SDK not fire scan event #476

Open
dilo99 opened this issue Aug 4, 2022 · 3 comments
Open

Android 12 SDK not fire scan event #476

dilo99 opened this issue Aug 4, 2022 · 3 comments

Comments

@dilo99
Copy link

dilo99 commented Aug 4, 2022

Hi, i setup properly the plugin, but when i build with SDK 31 or 32, the listener start correctly, th event of the bond of the listener correctly trigger, but no event trigger the onSuccess scan function...
the phone make the scan sound but no event is triggered
the sound of the scan is different from the phone default sound, so the sound i know that is from the plugin and not from the phone system listener, but no event is triggered!!
why?

@Master244
Copy link

Master244 commented Aug 5, 2022

I have the same issues on Iphone and Android

@Paradox7208
Copy link

Paradox7208 commented Aug 25, 2022

After making my own fork of this project and a bit of trial and error, I managed to get my Android 12 SDK firing the scan event. For reasons unknow to me as I am not an Android developer (I rely on Cordova), you need to set the intent flag to MUTABLE instead of IMMUTABLE.

If you read this section of the Android PendingIntent reference, Android used to treat all implicit PendingIntent references as MUTABLE. So I decided to explicity set that flag myself to replicate how the intent used to be created, and now my app scans NFC tags again.

I hope this works for you too!

https://developer.android.com/reference/android/app/PendingIntent#FLAG_MUTABLE
image

My repo that has the intent flag update which I will submit a pull request for.
https://github.com/Paradox7208/phonegap-nfc

Related pull request
#477

@Shadowsith
Copy link

Shadowsith commented Aug 29, 2022

@Paradox7208 thx for your fork.
I tried it out and it works very well for Android 12 (cordova [email protected], SDK 32)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants