This repository has been archived by the owner on Jan 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
74 lines (68 loc) · 2.04 KB
/
App.js
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
70
71
72
73
import React, {useEffect, useRef} from 'react';
import { StyleSheet} from 'react-native';
import FeaturesUpdate from './components/FeaturesUpdate';
import FeaturesTrial from './components/FeaturesTrial';
import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { CustomerIO } from 'customerio-reactnative';
const Stack = createNativeStackNavigator();
export default function App() {
useEffect(() => {
console.log("Welcome to Ami App ! ")
}, [])
// Automatic screen tracking
const navigationRef = useNavigationContainerRef();
const routeNameRef = useRef();
const config = {
screens: {
FeaturesTrial: 'showtrial',
},
};
const linking = {
prefixes: ['amiapp://'],
config
};
return (
// MARK:- AUTO SCREEN TRACKING
// Start
<NavigationContainer
ref={navigationRef}
linking={linking}
onReady={() => {
routeNameRef.current = navigationRef.getCurrentRoute().name;
}}
onStateChange={async () => {
const previousRouteName = routeNameRef.current;
const currentRouteName = navigationRef.getCurrentRoute().name;
if (previousRouteName !== currentRouteName) {
CustomerIO.screen(currentRouteName)
}
routeNameRef.current = currentRouteName;
}}
// End
>
<Stack.Navigator initialRouteName="FeaturesUpdate">
<Stack.Screen name="FeaturesUpdate"
component={FeaturesUpdate}
options={{
headerShown : false
}}/>
<Stack.Screen name="FeaturesTrial" component={FeaturesTrial}
options={{
title : "Let's Play",
headerStyle: {
backgroundColor: '#F6F7F9',
},
}} />
</Stack.Navigator>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
mainView: {
flex: 1,
flexDirection: 'row',
paddingTop : 50,
justifyContent:'center'
},
});