Skip to content

Fix/remove android beam - #508

Open
souleymane-diallo wants to merge 6 commits into
chariotsolutions:masterfrom
souleymane-diallo:fix/remove-android-beam
Open

Fix/remove android beam#508
souleymane-diallo wants to merge 6 commits into
chariotsolutions:masterfrom
souleymane-diallo:fix/remove-android-beam

Conversation

@souleymane-diallo

Copy link
Copy Markdown

Removal of Deprecated Android Beam Features in API 34

The chariotsolutions/phonegap-nfc plugin includes Android Beam features, which were deprecated in Android API 29 and
removed in API 34. As a result, the plugin is incompatible with Android 14.

  • To fix this, I removed the nfc.share, nfc.unshare, nfc.handover, and nfc.stopHandover functions from the NfcPlugin.java file.
  • The nfc.handover and nfc.stopHandover methods, specific to Android only, have also been removed from the JavaScript file
    phonegap-nfc.js and README

Files modified:

  • NfcPlugin.java
  • phonegap-nfc.js
  • README.md

@scr2em

scr2em commented May 16, 2024

Copy link
Copy Markdown

Hi @souleymane-diallo sadly this repo is not maintained for 4 years.

I have forked it here https://github.com/scr2em/phonegap-nfc and I'll maintain it and release it to npm under a new name. Can you help me and create a PR to it too?

Comment thread README.md Outdated
### Supported Platforms

- Android

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete one more line here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add this empty build.gradle?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this empty build.gradle

import android.util.Log;

public class NfcPlugin extends CordovaPlugin implements NfcAdapter.OnNdefPushCompleteCallback {
public class NfcPlugin extends CordovaPlugin {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, any info on why removing this implements NfcAdapter.OnNdefPushCompleteCallback can be done, or is necessary, or else?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing implements NfcAdapter.OnNdefPushCompleteCallback corresponds with Android Beam's phase-out in API 29 and its complete removal in API 34 for Android 14. This update keeps our plugin aligned with the latest Android standards and free from deprecated code.

@souleymane-diallo souleymane-diallo Jul 10, 2024

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface implements NfcAdapter.OnNdefPushCompleteCallback https://developer.android.com/reference/android/nfc/NfcAdapter.OnNdefPushCompleteCallback which includes the method @Override public void onNdefPushComplete(NfcEvent event). If we remove this interface, we must also remove the associated @Override. Since our goal is related to Android Beam, which is no longer supported, we no longer need to implement this interface or the @Override.

shareTag(data, callbackContext);

} else if (action.equalsIgnoreCase(UNSHARE_TAG)) {
unshareTag(callbackContext);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK to remove handover/stopHandover because directly related to Beam, as visible in the code here.
But why removing share/unshare? It seems to be related to "NdefPush"/"Push" ; is that part of Android Beam too?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of shareTag and unshareTag actions is due to their dependence on the NDEF push feature, which is primarily facilitated through Android Beam. Since Android Beam and related functionalities have been deprecated and removed in newer Android APIs, maintaining these actions would lead to future compatibility issues and potential security risks. This ensures our plugin stays updated with supported Android NFC capabilities.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android Beam https://developer.android.com/develop/connectivity/nfc/nfc#p2p a feature that utilized NFC for file sharing, is no longer supporte. Although it still exists in the SDK, it is not functional; the code does not compile and links to the documentation are non-existent.
Development guides once referred to "Beam file," https://developer.android.com/training/beam-files but this documentation has been removed and redirects to 'file sharing'. Specific links to Android Beam https://developer.android.com/reference/android/nfc/NfcAdapter as well as any dedicated documentation and its specific methods are no longer available.

@minorityuk

Copy link
Copy Markdown

@scr2em have you released this to NPM as I require to upgrade my android app to 34

@ath0mas

ath0mas commented Jul 10, 2024

Copy link
Copy Markdown

Merged in ns0m/cordova-plugin-ns0m-nfc and released in v1.3.0-5: published to cordova-plugin-ns0m-nfc.
Thanks @souleymane-diallo for the good work and details.

@Clo1420

Clo1420 commented Jul 11, 2024 via email

Copy link
Copy Markdown

@tmwebs

tmwebs commented Jul 17, 2024

Copy link
Copy Markdown

@souleymane-diallo thank you very much for your contribution, you saved my life.

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

Successfully merging this pull request may close these issues.

6 participants