Skip to content

Commit 049f6ab

Browse files
committed
docs: improve deep link testing instructions and logic
1 parent ccf266b commit 049f6ab

11 files changed

Lines changed: 43 additions & 23 deletions

File tree

examples/expo-bare/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ If you need more complex routing flows with a specific navigation library, check
3636
- Run prebuild for this example: `yarn prebuild`
3737
- Start the example: `yarn start`
3838
- Run on device/simulator: `yarn ios` or `yarn android`
39+
- Trigger test links: **deferred** — copy the link from Detour Dashboard before a fresh install, then install and launch (link resolves on first open). **Universal/App link** — open the link from Dashboard while the app is running. See **Test flow** for more detail.

examples/expo-router-advanced/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ Optional custom scheme test:
4343
- Run prebuild for this example: `yarn prebuild`
4444
- Start the example: `yarn start`
4545
- Run on device/simulator: `yarn ios` or `yarn android`
46+
- Trigger test links: **deferred** — copy the link from Detour Dashboard before a fresh install, then install and launch (link resolves on first open). **Universal/App link** — open the link from Dashboard while the app is running. **Custom scheme** — open `detour-expo-router-advanced://app/anything` directly. See **Test flow** for more detail.

examples/expo-router-native-intent/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ Result: when a universal/app link is opened, Expo Router receives the final rout
3838
- Run prebuild for this example: `yarn prebuild`
3939
- Start the example: `yarn start`
4040
- Run on device/simulator: `yarn ios` or `yarn android`
41+
- Trigger test links: **deferred** — copy the link from Detour Dashboard before a fresh install, then install and launch (link resolves on first open). **Universal/App link** — open the link from Dashboard while the app is running. See **Test flow** for more detail.

examples/expo-router/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ For more advanced use case with authentication, see `examples/expo-router-advanc
2424
- Run prebuild for this example: `yarn prebuild`
2525
- Start the example: `yarn start`
2626
- Run on device/simulator: `yarn ios` or `yarn android`
27+
- Trigger test links: **deferred** — copy the link from Detour Dashboard before a fresh install, then install and launch (link resolves on first open). **Universal/App link** — open the link from Dashboard while the app is running. See **Test flow** for more detail.

examples/react-navigation-advanced/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ This example demonstrates an auth-gated React Navigation app with Detour integra
4141
- Run prebuild for this example: `yarn prebuild`
4242
- Start the example: `yarn start`
4343
- Run on device/simulator: `yarn ios` or `yarn android`
44+
- Trigger test links: **deferred** — copy the link from Detour Dashboard before a fresh install, then install and launch (link resolves on first open). **Universal/App link** — open the link from Dashboard while the app is running. **Custom scheme** — open `detour-react-navigation-advanced://details` directly. See **Test flow** for more detail.

examples/react-navigation-advanced/src/App.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,12 @@ const AppRoot = () => {
151151
return;
152152
}
153153

154-
// toPendingDetailsRoute returns null for unrecognized paths, which allows us to show a NotFound screen for those while still handling known routes (e.g. /details/:id) that require authentication by saving a pending route if the user is not logged in.
155-
const pending = toPendingDetailsRoute(link.route, 'detour');
154+
// Convert the Detour link to a pending route if it's a known protected route that requires auth.
155+
// This example only has one protected route (Details) but this logic can be extended as needed.
156+
const pending = toPendingDetailsRoute(link.route, 'detour', {
157+
linkType: link.type,
158+
linkParams: link.params,
159+
});
156160
clearLink();
157161

158162
if (!pending) {
@@ -165,22 +169,11 @@ const AppRoot = () => {
165169

166170
// If the user is not logged in, save the pending route and navigate to Login. Otherwise, navigate to the resolved route.
167171
if (!isLoggedIn) {
168-
setPendingRoute({
169-
...pending,
170-
params: {
171-
...pending.params,
172-
linkType: link.type,
173-
linkParams: link.params,
174-
},
175-
});
172+
setPendingRoute(pending);
176173
navigationRef.navigate('Login');
177174
return;
178175
}
179-
navigationRef.navigate(pending.name, {
180-
...pending.params,
181-
linkType: link.type,
182-
linkParams: link.params,
183-
});
176+
navigationRef.navigate(pending.name, pending.params);
184177
}, [
185178
clearLink,
186179
isLinkProcessed,

examples/react-navigation-advanced/src/navigation/helpers.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ const normalizePath = (raw: string) => {
2727
// This helper function demonstrates how to parse incoming paths into pending route information for protected deep links specifically for the Details screen in this example.
2828
// Returning `null` means the link is silently discarded — no navigation occurs.
2929
// In a real app, this logic would likely be more complex and handle more routes and edge cases.
30+
// The `extra` parameter can include any additional information about the link that you want to include in the pending route params.
31+
// In this example, we include the original link type and parameters for demonstration purposes.
3032
export const toPendingDetailsRoute = (
3133
raw: string,
32-
source: 'detour' | 'linking'
34+
source: 'detour' | 'linking',
35+
extra?: { linkType?: string; linkParams?: Record<string, string> }
3336
): PendingRoute | null => {
3437
const path = normalizePath(raw);
3538
const pathname = path.split('?')[0] || '/';
@@ -40,7 +43,7 @@ export const toPendingDetailsRoute = (
4043

4144
return {
4245
name: 'Details',
43-
params: { fromDeepLink: true, source },
46+
params: { fromDeepLink: true, source, ...extra },
4447
};
4548
};
4649

examples/react-navigation-advanced/src/navigation/screens/Home.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@ export function Home() {
1919
</Text>
2020
<Text style={styles.instructions}>
2121
Try to open links that resolve to the details screen e.g.:{' '}
22-
<Text style={styles.bold}>/details</Text> or{' '}
23-
<Text style={styles.bold}>/details?id=42</Text>.
22+
<Text style={styles.bold}>/details</Text> (can include query
23+
parameters).
24+
</Text>
25+
<Text style={styles.instructions}>
26+
You can also test custom scheme links to see how they are handled by
27+
React Navigation Linking without Detour processing, e.g.:{' '}
28+
<Text style={styles.bold}>
29+
detour-react-navigation-advanced://details
30+
</Text>
2431
</Text>
2532
{pendingRoute && (
2633
<>

examples/react-navigation-advanced/src/navigation/screens/Login.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ export function Login() {
1414
resumes pending deep links after sign in.
1515
</Text>
1616
<Text style={styles.instructions}>
17-
Try links resolving to <Text style={styles.bold}>/details</Text> or{' '}
18-
<Text style={styles.bold}>/details?id=42</Text> while signed out. The
19-
app should keep a pending target and continue after login.
17+
Try links resolving to <Text style={styles.bold}>/details</Text> (can
18+
include query parameters) while signed out. The app should keep a
19+
pending target and continue after login.
20+
</Text>
21+
<Text style={styles.instructions}>
22+
You can also test custom scheme links to see how they are handled by
23+
React Navigation Linking without Detour processing, e.g.:{' '}
24+
<Text style={styles.bold}>
25+
detour-react-navigation-advanced://details
26+
</Text>
2027
</Text>
21-
2228
{pendingRoute && (
2329
<View style={styles.container}>
2430
<Text style={styles.sectionTitle}>Pending route</Text>

examples/react-navigation/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ This example demonstrates the minimal integration of `@swmansion/react-native-de
2828
- Run prebuild for this example: `yarn prebuild`
2929
- Start the example: `yarn start`
3030
- Run on device/simulator: `yarn ios` or `yarn android`
31+
- Trigger test links: **deferred** — copy the link from Detour Dashboard before a fresh install, then install and launch (link resolves on first open). **Universal/App link** — open the link from Dashboard while the app is running. See **Test flow** for more detail.

0 commit comments

Comments
 (0)