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

Fix/remove android beam #508

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

souleymane-diallo
Copy link

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
Copy link

scr2em commented May 16, 2024

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?

README.md Outdated

### Supported Platforms

- Android

Copy link

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

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
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

@@ -35,7 +33,7 @@
import android.os.Parcelable;
import android.util.Log;

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

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
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.

Copy link
Author

@souleymane-diallo souleymane-diallo Jul 10, 2024

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

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
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
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

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

@ath0mas
Copy link

ath0mas commented Jul 10, 2024

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
Copy link

Clo1420 commented Jul 11, 2024 via email

@tmwebs
Copy link

tmwebs commented Jul 17, 2024

@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