-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathHomeScreen.tsx
More file actions
69 lines (63 loc) · 1.97 KB
/
HomeScreen.tsx
File metadata and controls
69 lines (63 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import React, { useEffect } from 'react';
import { Text, TextInput, TouchableOpacity, View } from 'react-native';
import Intercom, { Visibility } from '@intercom/intercom-react-native';
import { requestNotifications } from 'react-native-permissions';
import { useIntercom } from '../hooks/useIntercom';
import { styles } from '../styles/App.styles';
export function HomeScreen(): React.JSX.Element {
useEffect(() => {
(async () => {
// Request permissions
await requestNotifications([
'alert',
'sound',
'criticalAlert',
'badge',
'provisional',
'carPlay',
'providesAppSettings',
]);
await Intercom.setLauncherVisibility(Visibility.VISIBLE);
})();
}, []);
const {
handleLoginIdentifiedUser,
handleLoginUnidentifiedUser,
handleLogout,
setUserIdentifier,
isLoggedIn,
} = useIntercom();
return (
<View style={styles.screenWrapper}>
<Text style={styles.title}>Push Notifications Sandbox</Text>
<View style={styles.wrapper}>
{!isLoggedIn ? (
<>
<TextInput
style={styles.input}
onChangeText={setUserIdentifier}
placeholder="Enter email address"
/>
<TouchableOpacity
style={styles.button}
onPress={handleLoginIdentifiedUser}
>
<Text style={styles.buttonText}>Login Identified User</Text>
</TouchableOpacity>
<View style={styles.divider} />
<TouchableOpacity
style={styles.button}
onPress={handleLoginUnidentifiedUser}
>
<Text style={styles.buttonText}>Login Unidentified User</Text>
</TouchableOpacity>
</>
) : (
<TouchableOpacity style={styles.button} onPress={handleLogout}>
<Text style={styles.buttonText}>Logout</Text>
</TouchableOpacity>
)}
</View>
</View>
);
}