diff --git a/app/src/Navigation.tsx b/app/src/Navigation.tsx
index 0c428a199..57e9b543e 100644
--- a/app/src/Navigation.tsx
+++ b/app/src/Navigation.tsx
@@ -42,9 +42,11 @@ import PassportDataInfoScreen from './screens/Settings/PassportDataInfoScreen';
import ShowRecoveryPhraseScreen from './screens/Settings/ShowRecoveryPhraseScreen';
import SettingsScreen from './screens/SettingsScreen';
import SplashScreen from './screens/SplashScreen';
-import { ProofProvider } from './stores/proofProvider';
+import { useApp } from './stores/appProvider';
+import { useProofInfo } from './stores/proofProvider';
import analytics from './utils/analytics';
import { black, slate300, white } from './utils/colors';
+import { setupUniversalLinkListenerInNavigation } from './utils/qrCodeNew';
const AppNavigation = createNativeStackNavigator({
initialRouteName: 'Splash',
@@ -349,11 +351,27 @@ const NavigationWithTracking = () => {
}
};
+ // Add these hooks to get access to the necessary functions
+ const { setSelectedApp, cleanSelfApp } = useProofInfo();
+ const { startAppListener } = useApp();
+
+ // Setup universal link handling at the navigation level
+ React.useEffect(() => {
+ const cleanup = setupUniversalLinkListenerInNavigation(
+ navigationRef,
+ setSelectedApp,
+ cleanSelfApp,
+ startAppListener,
+ );
+
+ return () => {
+ cleanup();
+ };
+ }, [setSelectedApp, cleanSelfApp, startAppListener]);
+
return (
-
-
-
+
);
};
diff --git a/app/src/screens/Onboarding/LoadingScreen.tsx b/app/src/screens/Onboarding/LoadingScreen.tsx
index 59c5b6303..497af528c 100644
--- a/app/src/screens/Onboarding/LoadingScreen.tsx
+++ b/app/src/screens/Onboarding/LoadingScreen.tsx
@@ -48,6 +48,7 @@ const LoadingScreen: React.FC = ({}) => {
}, []);
useEffect(() => {
+ console.log('registrationStatus', registrationStatus);
if (registrationStatus === ProofStatusEnum.SUCCESS) {
setAnimationSource(successAnimation);
goToSuccessScreenWithDelay();
diff --git a/app/src/stores/proofProvider.tsx b/app/src/stores/proofProvider.tsx
index 8f74a59e4..d4312ac67 100644
--- a/app/src/stores/proofProvider.tsx
+++ b/app/src/stores/proofProvider.tsx
@@ -8,10 +8,6 @@ import React, {
} from 'react';
import { SelfApp } from '../../../common/src/utils/appType';
-import { navigationRef } from '../Navigation';
-import { useApp } from '../stores/appProvider';
-import { setupUniversalLinkListener } from '../utils/qrCodeNew';
-import { usePassport } from './passportDataProvider';
export enum ProofStatusEnum {
PENDING = 'pending',
@@ -63,7 +59,6 @@ export let globalSetDisclosureStatus:
store to manage the proof verification process, including app the is requesting, intemidiate status and final result
*/
export function ProofProvider({ children }: PropsWithChildren<{}>) {
- const { passportData, secret } = usePassport(false);
const [registrationStatus, setRegistrationStatus] = useState(
ProofStatusEnum.PENDING,
);
@@ -75,8 +70,6 @@ export function ProofProvider({ children }: PropsWithChildren<{}>) {
defaults.selectedApp,
);
- const { startAppListener } = useApp();
-
const setSelectedApp = useCallback((app: SelfApp) => {
if (!app || Object.keys(app).length === 0) {
return;
@@ -96,24 +89,6 @@ export function ProofProvider({ children }: PropsWithChildren<{}>) {
setDisclosureStatus(ProofStatusEnum.PENDING);
}, []);
- const handleNavigateToProveScreen = useCallback(() => {
- if (navigationRef.isReady()) {
- navigationRef.navigate('ProveScreen');
- } else {
- console.log("Navigation not ready yet, couldn't navigate to ProveScreen");
- }
- }, []);
-
- const handleNavigateToQRCodeTrouble = useCallback(() => {
- if (navigationRef.isReady()) {
- navigationRef.navigate('QRCodeTrouble');
- } else {
- console.log(
- "Navigation not ready yet, couldn't navigate to QRCodeTrouble",
- );
- }
- }, []);
-
useEffect(() => {
globalSetRegistrationStatus = setRegistrationStatus;
globalSetDisclosureStatus = setDisclosureStatus;
@@ -123,27 +98,6 @@ export function ProofProvider({ children }: PropsWithChildren<{}>) {
};
}, []);
- useEffect(() => {
- if (passportData && secret) {
- const universalLinkCleanup = setupUniversalLinkListener(
- setSelectedApp,
- cleanSelfApp,
- startAppListener,
- handleNavigateToProveScreen,
- handleNavigateToQRCodeTrouble,
- );
- return () => {
- universalLinkCleanup();
- };
- }
- }, [
- setSelectedApp,
- cleanSelfApp,
- startAppListener,
- handleNavigateToProveScreen,
- handleNavigateToQRCodeTrouble,
- ]);
-
const publicApi: IProofContext = useMemo(
() => ({
registrationStatus,
diff --git a/app/src/utils/qrCodeNew.ts b/app/src/utils/qrCodeNew.ts
index 182b09eeb..1dc9fb23e 100644
--- a/app/src/utils/qrCodeNew.ts
+++ b/app/src/utils/qrCodeNew.ts
@@ -67,35 +67,39 @@ const handleQRCodeData = (
}
};
-export const setupUniversalLinkListener = (
+export const setupUniversalLinkListenerInNavigation = (
+ navigation: any,
setApp: (app: SelfApp) => void,
cleanSelfApp: () => void,
startAppListener: (sessionId: string, setApp: (app: SelfApp) => void) => void,
- onNavigationNeeded?: () => void,
- onErrorCallback?: () => void,
) => {
- Linking.getInitialURL().then(url => {
- if (url) {
- handleQRCodeData(
- url,
- setApp,
- cleanSelfApp,
- startAppListener,
- onNavigationNeeded,
- onErrorCallback,
- );
- }
- });
-
- const linkingEventListener = Linking.addEventListener('url', ({ url }) => {
+ const handleNavigation = (url: string) => {
handleQRCodeData(
url,
setApp,
cleanSelfApp,
startAppListener,
- onNavigationNeeded,
- onErrorCallback,
+ () => {
+ if (navigation.isReady()) {
+ navigation.navigate('ProveScreen');
+ }
+ },
+ () => {
+ if (navigation.isReady()) {
+ navigation.navigate('QRCodeTrouble');
+ }
+ },
);
+ };
+
+ Linking.getInitialURL().then(url => {
+ if (url) {
+ handleNavigation(url);
+ }
+ });
+
+ const linkingEventListener = Linking.addEventListener('url', ({ url }) => {
+ handleNavigation(url);
});
return () => {