From 012af05ab8a26e34d99eb619ab58ef7dd07e5646 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Mon, 13 Jun 2022 20:52:40 -0500 Subject: Add universal links (iOS) --- src/routes/index.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/routes/index.tsx b/src/routes/index.tsx index a8a92e54f..5084473ec 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -1,5 +1,5 @@ -import React from 'react' -import {Text} from 'react-native' +import React, {useEffect} from 'react' +import {Text, Linking} from 'react-native' import { NavigationContainer, LinkingOptions, @@ -24,6 +24,7 @@ import {NotFound} from '../screens/NotFound' const linking: LinkingOptions = { prefixes: [ 'http://localhost:3000', // local dev + 'https://pubsq.pfrazee.com', // test server (universal links only) ], config: { screens: { @@ -59,6 +60,16 @@ const HIDE_TAB = {tabBarButton: () => null} export const Root = observer(() => { const store = useStores() + useEffect(() => { + console.log('Initial link setup') + Linking.getInitialURL().then((url: string | null) => { + console.log('Initial url', url) + }) + Linking.addEventListener('url', ({url}) => { + console.log('Deep link opened with', url) + }) + }, []) + // hide the tabbar on desktop web const tabBar = platform.isDesktopWeb ? () => null : undefined -- cgit 1.4.1