/
App.tsx
39 lines (34 loc) · 864 Bytes
/
App.tsx
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
import React, { useEffect } from 'react';
import { AppState, StyleSheet, View, Text, AppStateStatus } from 'react-native';
import { Intent, getIntent } from 'react-native-get-intent';
export default function App() {
const [intent, setIntent] = React.useState<Intent>();
useEffect(() => {
const subscription = AppState.addEventListener(
'change',
(state: AppStateStatus) => {
if (state === 'active') {
getIntent().then(setIntent);
}
}
);
return subscription.remove;
}, []);
return (
<View style={styles.container}>
<Text>Intent: {JSON.stringify(intent, null, 2)}</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
box: {
width: 60,
height: 60,
marginVertical: 20,
},
});