Skip to content

Commit

Permalink
Merge pull request #703 from icedevml/feature/restart-tech-req
Browse files Browse the repository at this point in the history
Implement restartTechnologyRequestIOS
  • Loading branch information
whitedogg13 authored Mar 7, 2024
2 parents c8e8a9d + 2838607 commit a282d65
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ declare module 'react-native-nfc-manager' {
le: number;
},
) => Promise<{response: number[]; sw1: number; sw2: number}>;
restartTechnologyRequestIOS: () => Promise<NfcTech | null>;
iso15693HandlerIOS: Iso15693HandlerIOS;

/**
Expand Down
15 changes: 15 additions & 0 deletions ios/NfcManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,21 @@ + (BOOL)requiresMainQueueSetup
}
}

RCT_EXPORT_METHOD(restartTechnologyRequest:(nonnull RCTResponseSenderBlock)callback)
{
if (@available(iOS 13.0, *)) {
if (tagSession != nil) {
NSLog(@"NfcManager restarting polling");
[self->tagSession restartPolling];
techRequestCallback = callback;
} else {
callback(@[@"No active registration", [NSNull null]]);
}
} else {
callback(@[@"Not support in this device", [NSNull null]]);
}
}

RCT_EXPORT_METHOD(cancelTechnologyRequest:(nonnull RCTResponseSenderBlock)callback)
{
if (@available(iOS 13.0, *)) {
Expand Down
2 changes: 2 additions & 0 deletions src/NfcManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class NfcManagerBase {

requestTechnology = NotImpl;

restartTechnologyRequestIOS = NotImpl;

cancelTechnologyRequest = NotImpl;

getBackgroundTag = NotImpl;
Expand Down
6 changes: 6 additions & 0 deletions src/NfcManagerIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ class NfcManagerIOS extends NfcManagerBase {
);
};

restartTechnologyRequestIOS = async () => {
return handleNativeException(
callNative('restartTechnologyRequest'),
);
};

cancelTechnologyRequest = async (options = {}) => {
const {throwOnError = false} = options;
return handleNativeException(
Expand Down

0 comments on commit a282d65

Please sign in to comment.