Skip to content

Commit

Permalink
test rn signInWithRedirect android fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashwin Kumar committed Jul 11, 2024
1 parent e3a10ca commit bf9882b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/rtn-web-browser/src/apis/openAuthSessionAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { nativeModule } from '../nativeModule';

let appStateListener: NativeEventSubscription | undefined;
let redirectListener: NativeEventSubscription | undefined;
let previousState = AppState.currentState;

export const openAuthSessionAsync = async (
url: string,
Expand Down Expand Up @@ -58,13 +59,13 @@ const openAuthSessionAndroid = async (url: string, redirectUrls: string[]) => {
// open chrome tab
nativeModule.openAuthSessionAsync(url),
]);

return redirectUrl;
} finally {
appStateListener?.remove();
redirectListener?.remove();
appStateListener = undefined;
redirectListener = undefined;
previousState = AppState.currentState;
}
};

Expand All @@ -76,11 +77,12 @@ const getAppStatePromise = (): Promise<null> =>
return;
}

if (nextAppState === 'active') {
if (nextAppState === 'active' && previousState !== 'active') {
appStateListener?.remove();
appStateListener = undefined;
resolve(null);
}
previousState = nextAppState;
});
});

Expand Down

0 comments on commit bf9882b

Please sign in to comment.