Skip to content

Commit

Permalink
fix: promise won't be rejected when calling cancelTechnologyRequest in
Browse files Browse the repository at this point in the history
iOS
  • Loading branch information
whitedogg13 committed Jan 18, 2020
1 parent 6ddbb08 commit 64c9cbd
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions NfcManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ class NfcManager {
await this.registerTagEvent(options);
}

// the tag registration is
this.cleanUpTagRegistration = true;
}

Expand All @@ -207,31 +206,33 @@ class NfcManager {
}

cancelTechnologyRequest = async () => {
await callNative('cancelTechnologyRequest');
if (!this.cleanUpTagRegistration) {
await callNative('cancelTechnologyRequest');
return;
}

if (this.cleanUpTagRegistration) {
this.cleanUpTagRegistration = false;
this.cleanUpTagRegistration = false;

if (Platform.OS === 'ios') {
let sessionAvailable = false;

// because we don't know which tech currently requested
// so we try both, and perform early return when hitting any
sessionAvailable = await this._isSessionExAvailableIOS();
if (sessionAvailable) {
await this._unregisterTagEventExIOS();
return;
}
if (Platform.OS === 'ios') {
let sessionAvailable = false;

sessionAvailable = await this._isSessionAvailableIOS();
if (sessionAvailable) {
await this.unregisterTagEvent();
return;
}
} else {
// because we don't know which tech currently requested
// so we try both, and perform early return when hitting any
sessionAvailable = await this._isSessionExAvailableIOS();
if (sessionAvailable) {
await this._unregisterTagEventExIOS();
return;
}

sessionAvailable = await this._isSessionAvailableIOS();
if (sessionAvailable) {
await this.unregisterTagEvent();
return;
}
} else {
await callNative('cancelTechnologyRequest');
await this.unregisterTagEvent();
return;
}
}

Expand Down

0 comments on commit 64c9cbd

Please sign in to comment.