Skip to content

Commit b1f1c2e

Browse files
authored
IOS deep link (#772)
* add deep link changes * remove http protocol from entitlements
1 parent c3b5fb5 commit b1f1c2e

4 files changed

Lines changed: 68 additions & 4 deletions

File tree

api/apple-app-site-association.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export default function handler(_req: any, res: any) {
2+
res.setHeader("Content-Type", "application/json");
3+
res.status(200).send({
4+
applinks: {
5+
apps: [],
6+
details: [
7+
{
8+
appID: "48TB6ZZL5S.io.agora.app.builder.conferencing",
9+
paths: ["*", "/"],
10+
},
11+
{
12+
appID: "34FKK829T7.org.reactjs.native.example.test.Helloworld",
13+
paths: ["*", "/"],
14+
},
15+
],
16+
},
17+
});
18+
}

template/ios/HelloWorld/HelloWorld.entitlements

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<dict>
55
<key>com.apple.developer.associated-domains</key>
66
<array>
7-
<string>applinks:FRONTEND_ENDPOINT_BASE</string>
7+
<string>applinks:app-builder-core-git-preprod-agoraio.vercel.app</string>
8+
<string>applinks:conferencing.agora.io</string>
89
</array>
910
</dict>
1011
</plist>

template/src/auth/AuthProvider.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ const AuthProvider = (props: AuthProviderProps) => {
135135
}
136136
}, [store?.token]);
137137

138+
// Handle navigation in native apps when authentication completes with pending returnTo
139+
useEffect(() => {
140+
if (authenticated && returnTo && (isAndroid() || isIOS())) {
141+
history.push(returnTo);
142+
setReturnTo('');
143+
}
144+
}, [authenticated, returnTo]);
145+
138146
const deepLinkUrl = (link: string | null) => {
139147
if (link !== null) {
140148
//deeplinking handling with authentication enabled
@@ -201,9 +209,14 @@ const AuthProvider = (props: AuthProviderProps) => {
201209
history.push('/');
202210
}
203211
} else {
204-
//deeplinking handling with authentication enabled
212+
//deeplinking handling with authentication disabled
205213
const url = processDeepLinkURI(link);
206-
setReturnTo(url);
214+
// If already authenticated, navigate immediately
215+
if (authenticated && url) {
216+
history.push(url);
217+
} else {
218+
setReturnTo(url);
219+
}
207220
}
208221
}
209222
};

vercel.json

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
11
{
2-
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
2+
"rewrites": [
3+
{
4+
"source": "/.well-known/apple-app-site-association",
5+
"destination": "/api/apple-app-site-association"
6+
},
7+
{
8+
"source": "/apple-app-site-association",
9+
"destination": "/api/apple-app-site-association"
10+
},
11+
{ "source": "/(.*)", "destination": "/index.html" }
12+
],
13+
"headers": [
14+
{
15+
"source": "/.well-known/apple-app-site-association",
16+
"headers": [
17+
{
18+
"key": "Content-Type",
19+
"value": "application/json"
20+
},
21+
{ "key": "Cache-Control", "value": "no-store" }
22+
]
23+
},
24+
{
25+
"source": "/apple-app-site-association",
26+
"headers": [
27+
{
28+
"key": "Content-Type",
29+
"value": "application/json"
30+
},
31+
{ "key": "Cache-Control", "value": "no-store" }
32+
]
33+
}
34+
]
335
}

0 commit comments

Comments
 (0)