Skip to content

Commit

Permalink
Merge pull request #659 from revtel/fix/remove-set-ndef-push-android
Browse files Browse the repository at this point in the history
fix: remove deprecated android api setNdefPushMessages
  • Loading branch information
whitedogg13 authored Aug 24, 2023
2 parents 8b11fec + 35a8f8a commit 92cfc15
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 30 deletions.
28 changes: 0 additions & 28 deletions android/src/main/java/community/revteltech/nfc/NfcManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -948,34 +948,6 @@ public void requestNdefWrite(ReadableArray rnArray, ReadableMap options, Callbac
}
}

@ReactMethod
public void setNdefPushMessage(ReadableArray rnArray, Callback callback) {
synchronized(this) {
if (techRequest == null && writeNdefRequest == null) {
try {
Activity currentActivity = getCurrentActivity();
if (currentActivity == null) {
throw new RuntimeException("cannot get current activity");
}

NdefMessage msgToPush = null;
if (rnArray != null) {
msgToPush = new NdefMessage(rnArrayToBytes(rnArray));
}

NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(context);
nfcAdapter.setNdefPushMessage(msgToPush, currentActivity);
callback.invoke();
} catch (Exception ex) {
Log.d(LOG_TAG, ex.toString());
callback.invoke(ex.toString());
}
} else {
callback.invoke(ERR_MULTI_REQ);
}
}
}

@ReactMethod
public void start(Callback callback) {
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(context);
Expand Down
5 changes: 3 additions & 2 deletions src/NfcManagerAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ class NfcManagerAndroid extends NfcManagerBase {
getLaunchTagEvent = () =>
handleNativeException(callNative('getLaunchTagEvent'));

setNdefPushMessage = (bytes) =>
handleNativeException(callNative('setNdefPushMessage', [bytes]));
setNdefPushMessage = (bytes) => {
return Promise.reject('this api is deprecated');
}

setTimeout = (timeout) =>
handleNativeException(callNative('setTimeout', [timeout]));
Expand Down

0 comments on commit 92cfc15

Please sign in to comment.