Skip to content

Commit

Permalink
Merge pull request #536 from revtel/fix/android-nfc-setting-ex
Browse files Browse the repository at this point in the history
fix(android): avoid native exception while jumping to system NFC settings
  • Loading branch information
whitedogg13 authored Jun 25, 2022
2 parents 899856d + 9607b50 commit 0ea6a38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1034,8 +1034,12 @@ public void goToNfcSetting(Callback callback) {
return;
}

currentActivity.startActivity(new Intent(Settings.ACTION_NFC_SETTINGS));
callback.invoke();
try {
currentActivity.startActivity(new Intent(Settings.ACTION_NFC_SETTINGS));
callback.invoke(null, true);
} catch (Exception ex) {
callback.invoke(null, false);
}
}

@ReactMethod
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ declare module 'react-native-nfc-manager' {
/**
* Android only
*/
goToNfcSetting(): Promise<any>;
goToNfcSetting(): Promise<boolean>;
getLaunchTagEvent(): Promise<TagEvent | null>;
transceive(bytes: number[]): Promise<number[]>;
getMaxTransceiveLength(): Promise<number>;
Expand Down

0 comments on commit 0ea6a38

Please sign in to comment.