diff --git a/native/navigation/deep-links-context-provider.react.js b/native/navigation/deep-links-context-provider.react.js --- a/native/navigation/deep-links-context-provider.react.js +++ b/native/navigation/deep-links-context-provider.react.js @@ -12,6 +12,7 @@ import { parseSecretFromInviteLinkURL, parseInstallReferrerFromInviteLinkURL, + parseKeysFromQRCodeURL, } from 'lib/facts/links.js'; import { isLoggedIn } from 'lib/selectors/user-selectors.js'; import type { SetState } from 'lib/types/hook-types.js'; @@ -20,7 +21,10 @@ useServerCall, } from 'lib/utils/action-utils.js'; -import { InviteLinkModalRouteName } from './route-names.js'; +import { + InviteLinkModalRouteName, + SecondaryDeviceQRCodeScannerRouteName, +} from './route-names.js'; import { useSelector } from '../redux/redux-utils.js'; import { useOnFirstLaunchEffect } from '../utils/hooks.js'; @@ -48,7 +52,7 @@ const subscription = Linking.addEventListener('url', ({ url }) => setCurrentLink(url), ); - // We're also checking if the app was opened by using an invite link. + // We're also checking if the app was opened by using a link. // In that case the listener won't be called and we're instead checking // if the initial URL is set. (async () => { @@ -92,24 +96,26 @@ setCurrentLink(null); const secret = parseSecretFromInviteLinkURL(currentLink); - if (!secret) { - return; - } - - const validateLinkPromise = validateLink({ secret }); - dispatchActionPromise(verifyInviteLinkActionTypes, validateLinkPromise); - const result = await validateLinkPromise; - if (result.status === 'already_joined') { - return; + const keys = parseKeysFromQRCodeURL(currentLink); + + if (secret) { + const validateLinkPromise = validateLink({ secret }); + dispatchActionPromise(verifyInviteLinkActionTypes, validateLinkPromise); + const result = await validateLinkPromise; + if (result.status === 'already_joined') { + return; + } + + navigation.navigate<'InviteLinkModal'>({ + name: InviteLinkModalRouteName, + params: { + invitationDetails: result, + secret, + }, + }); + } else if (keys) { + navigation.navigate(SecondaryDeviceQRCodeScannerRouteName); } - - navigation.navigate<'InviteLinkModal'>({ - name: InviteLinkModalRouteName, - params: { - invitationDetails: result, - secret, - }, - }); })(); }, [currentLink, dispatchActionPromise, loggedIn, navigation, validateLink]);