chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
703 stars 547 forks source link

Android 12 PendingIntent Fix #477

Open Paradox7208 opened 1 year ago

Paradox7208 commented 1 year ago

Android 12 is known to crash on launch if the Intent flag is not explicitly set to MUTABLE or IMMUTABLE.

Upon further testing, NFC tags would not scan when the App is in focus when the flag is set to IMMUTABLE. I decided to use the MUTABLE flag instead which is the default flag for a PendingIntent activity and NFC tags scan as normal.

https://developer.android.com/reference/android/app/PendingIntent#FLAG_MUTABLE _"Up until Build.VERSION_CODES.R, PendingIntents are assumed to be mutable by default, unless FLAG_IMMUTABLE is set. Starting with Build.VERSION_CODES.S, it will be required to explicitly specify the mutability of PendingIntents on creation with either FLAG_IMMUTABLE or FLAGMUTABLE"

MrElectroNick commented 1 year ago

Hi @don, @krimple, @gonzalo123, @doncoleman - any updates on this?

popovitsj commented 1 year ago

Why is this checking for android.os.Build.VERSION_CODES.M (23) instead of S, which is 31?

Paradox7208 commented 1 year ago

@popovitsj that's a fair point. When I first put this fix together, I used code that I found in other similar forks of this project and pieced together the code seen in this pull request.

I am by no means an Android developer, my solution worked for me and it seems to work for others. Any improvements to the code is welcomed.

popovitsj commented 1 year ago

The safest would be to change the check for M to S. Alternatively, we could check if we could just include the flag for all api versions, but it would require more testing effort.

Op ma 14 nov. 2022 22:26 schreef Paradox7208 @.***>:

@popovitsj https://github.com/popovitsj that's a fair point. When I first put this fix together, I used code that I found in other similar forks of this project and pieced together the code seen in this pull request.

I am by no means an Android developer, my solution worked for me and it seems to work for others. Any improvements to the code is welcomed.

— Reply to this email directly, view it on GitHub https://github.com/chariotsolutions/phonegap-nfc/pull/477#issuecomment-1314404097, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWTKOB6IPYMBGO5WKEUXLLWIKU7TANCNFSM57RFOTLA . You are receiving this because you were mentioned.Message ID: @.***>

Paradox7208 commented 1 year ago

@popovitsj I agree, it would be better to target S as the requirement to explicitly state the PendingIntent flag was introduced in this API version. I suspect it would be considered a "breaking" change to suddenly start explicitly setting the PendingIntent flag for every API level.

PetervLeeuwen commented 1 year ago

Any idea when this PR will be merged?

laurensk commented 1 year ago

Last commit to master was back in 2020. Is this plugin still maintained?

Laith-Bzour90 commented 12 months ago

when this PR will be merged ? this fix issue on android 12

laurensk commented 12 months ago

when this PR will be merged ? this fix issue on android 12

I actually wrote my own library because this seems to get no attention...

MrElectroNick commented 12 months ago

when this PR will be merged ? this fix issue on android 12

I actually wrote my own library because this seems to get no attention...

Can you point on repository maybe?

laurensk commented 12 months ago

when this PR will be merged ? this fix issue on android 12

I actually wrote my own library because this seems to get no attention...

Can you point on repository maybe?

It's not open source since I only implemented certain features we needed internally.