From 2fc9bd476b0d9abcddb0a46f615a48333779d225 Mon Sep 17 00:00:00 2001 From: tiberiusteng Date: Thu, 31 Oct 2024 16:19:13 +0800 Subject: [PATCH] Mobile: Fixes #9204: Handle callback url triggered app launch (#11280) Co-authored-by: Tib Teng <661892+tiberiusteng@users.noreply.github.com> Co-authored-by: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Co-authored-by: Laurent Cozic --- packages/app-mobile/root.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/app-mobile/root.tsx b/packages/app-mobile/root.tsx index d1b2a3637..a7de655bd 100644 --- a/packages/app-mobile/root.tsx +++ b/packages/app-mobile/root.tsx @@ -948,6 +948,21 @@ class AppComponent extends React.Component { throw error; } + // https://reactnative.dev/docs/linking#handling-deep-links + // + // The handler added with Linking.addEventListener() is only triggered when app is already open. + // + // When the app is not already open and the deep link triggered app launch, + // the URL can be obtained with Linking.getInitialURL(). + // + // We only save the URL here since we want to show the content only + // after biometrics check is passed or known disabled. + const url = await Linking.getInitialURL(); + if (url && isCallbackUrl(url)) { + logger.info('received initial callback url: ', url); + this.callbackUrl = url; + } + const loadedSensorInfo = await sensorInfo(); this.setState({ sensorInfo: loadedSensorInfo });