Skip to content

Commit 19de7d1

Browse files
committed
Set up dynamic links
Former-commit-id: 2fe9404 Former-commit-id: 74ec6cd
1 parent 535512a commit 19de7d1

File tree

4 files changed

+62
-19
lines changed

4 files changed

+62
-19
lines changed

App.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function App() {
1616
<ActionSheetProvider>
1717
<NavigationContainer
1818
linking={{
19-
prefixes: ["https://dogether.gg", "dogether://"],
19+
prefixes: ["https://dogether-78b6f.web.app", "dogether://"],
2020
config: {
2121
screens: {
2222
Login: "login",
@@ -31,6 +31,12 @@ export default function App() {
3131
},
3232
},
3333
},
34+
User: {
35+
path: "user/:id",
36+
parse: {
37+
id: (id) => Number(id),
38+
},
39+
},
3440
},
3541
}}
3642
>

app.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
"updates": {
1515
"fallbackToCacheTimeout": 0
1616
},
17-
"assetBundlePatterns": [
18-
"**/*"
19-
],
17+
"assetBundlePatterns": ["**/*"],
2018
"ios": {
2119
"bundleIdentifier": "gg.dogether.app",
2220
"supportsTablet": true
@@ -26,7 +24,21 @@
2624
"adaptiveIcon": {
2725
"foregroundImage": "./assets/adaptive-icon.png",
2826
"backgroundColor": "#FFFFFF"
29-
}
27+
},
28+
"intentFilters": [
29+
{
30+
"action": "VIEW",
31+
"autoVerify": true,
32+
"data": [
33+
{
34+
"scheme": "https",
35+
"host": "dogether.page.link",
36+
"pathPrefix": "/"
37+
}
38+
],
39+
"category": ["BROWSABLE", "DEFAULT"]
40+
}
41+
]
3042
},
3143
"web": {
3244
"favicon": "./assets/favicon.png"

screens/Login.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default function Login() {
8181
returnKeyType="next"
8282
keyboardType="email-address"
8383
onChangeText={setEmail}
84-
onSubmitEditing={passwordInputRef.current.focus}
84+
onSubmitEditing={passwordInputRef?.current?.focus}
8585
value={email}
8686
/>
8787
<TextInput

screens/Partner.js

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
1-
import React from "react";
2-
import {
3-
View,
4-
Text,
5-
StyleSheet,
6-
Pressable,
7-
TouchableOpacity,
8-
} from "react-native";
91
import * as Clipboard from "expo-clipboard";
10-
import InlineBtn from "../components/InlineBtn";
2+
import React from "react";
3+
import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
4+
5+
import { auth } from "../config";
6+
7+
const WEB_API_KEY = "AIzaSyCJ2FY69u3jR8WMVLCT_TDrkKyqkUE2Y3k";
8+
9+
const copyInvitationUrl = async () => {
10+
try {
11+
const payload = {
12+
dynamicLinkInfo: {
13+
domainUriPrefix: "https://dogether.page.link",
14+
link: `https://dogether-78b6f.web.app/user/${auth.currentUser.uid}`,
15+
androidInfo: {
16+
androidPackageName: "gg.dogether.app",
17+
},
18+
socialMetaTagInfo: {
19+
socialTitle: `New invite from ${auth.currentUser.displayName}`,
20+
socialDescription: `${auth.currentUser.displayName} is using Dogether to stay accountable and motivated. Join them on their journey!`,
21+
// socialImageLink: "<image-url>",
22+
},
23+
},
24+
};
1125

12-
const copyToClipboard = async () => {
13-
await Clipboard.setStringAsync("Hello World");
14-
alert("Copied to Clipboard!");
26+
const url = `https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=${WEB_API_KEY}`;
27+
const response = await fetch(url, {
28+
method: "POST",
29+
headers: {
30+
"Content-Type": "application/json",
31+
},
32+
body: JSON.stringify(payload),
33+
});
34+
const json = await response.json();
35+
await Clipboard.setStringAsync(json.shortLink);
36+
alert("Copied to Clipboard!");
37+
} catch (error) {
38+
alert(error.message);
39+
}
1540
};
1641
const Partner = () => {
1742
return (
1843
<View style={styles.container}>
1944
<Text style={styles.message}>Oops! You don't have a partner yet!</Text>
20-
<TouchableOpacity style={styles.button} onPress={copyToClipboard}>
45+
<TouchableOpacity style={styles.button} onPress={copyInvitationUrl}>
2146
<Text>Share link</Text>
2247
</TouchableOpacity>
2348
</View>

0 commit comments

Comments
 (0)