fix deeplink implementation (#472)

* fix deeplink implementation

* check biometrics when pressing button on prove screen

* Revert "check biometrics when pressing button on prove screen"

This reverts commit 88b1e891a7.

---------

Co-authored-by: 0xturboblitz <florent.tavernier@gmail.com>
This commit is contained in:
turnoffthiscomputer
2025-03-21 21:25:09 -04:00
committed by GitHub
parent e36d621f4d
commit 84ebc0fc21
4 changed files with 46 additions and 45 deletions

View File

@@ -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 (
<GestureHandlerRootView>
<ProofProvider>
<Navigation ref={navigationRef} onStateChange={trackScreen} />
</ProofProvider>
<Navigation ref={navigationRef} onStateChange={trackScreen} />
</GestureHandlerRootView>
);
};

View File

@@ -48,6 +48,7 @@ const LoadingScreen: React.FC<LoadingScreenProps> = ({}) => {
}, []);
useEffect(() => {
console.log('registrationStatus', registrationStatus);
if (registrationStatus === ProofStatusEnum.SUCCESS) {
setAnimationSource(successAnimation);
goToSuccessScreenWithDelay();

View File

@@ -8,8 +8,6 @@ import React, {
} from 'react';
import { SelfApp } from '../../../common/src/utils/appType';
import { navigationRef } from '../Navigation';
import { useApp } from '../stores/appProvider';
export enum ProofStatusEnum {
PENDING = 'pending',
@@ -72,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;
@@ -93,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;

View File

@@ -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 () => {