-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
100 lines (86 loc) · 2.43 KB
/
App.tsx
File metadata and controls
100 lines (86 loc) · 2.43 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React, { useEffect } from 'react';
import {
Button,
Text,
SafeAreaView,
ScrollView,
StatusBar,
useColorScheme,
View,
Platform,
} from 'react-native';
import messaging from '@react-native-firebase/messaging';
import FinBoxRiskSdk from 'react-native-risk-sdk';
import { Colors } from 'react-native/Libraries/NewAppScreen';
import {request, PERMISSIONS} from 'react-native-permissions';
const API_KEY = '';
const CUSTOMER_ID = 'demo_lender_1171440';
function createUser() {
FinBoxRiskSdk.createUser(
API_KEY,
CUSTOMER_ID,
(errorStatus: any) => {
// Error Callback
console.log('Error status -> ', errorStatus);
},
(msg: any) => {
// Success Callback, Call the periodic sync once the user has been created
console.log('Final message', msg);
FinBoxRiskSdk.startPeriodicSync(12); //Start the sync periodically after every 12 hour
},
);
}
function requestPermissions() {
const locationPermission = Platform.select({
ios: PERMISSIONS.IOS.LOCATION_WHEN_IN_USE,
android: PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION,
});
request(locationPermission).then(result => {
console.log('Permission granted', result);
createUser();
});
}
function App(): JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
useEffect(() => {
const unsubscribe = messaging().onMessage(async remoteMessage => {
console.log('A new FCM message!', remoteMessage.data);
FinBoxRiskSdk.forwardFinBoxNotificationToSDK(remoteMessage.data);
});
return unsubscribe;
}, []);
return (
<SafeAreaView style={backgroundStyle}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<Text>{CUSTOMER_ID}</Text>
<Button
onPress={requestPermissions}
title="Create User"
color="#007AFF"
accessibilityLabel="Create User"
/>
</View>
</ScrollView>
</SafeAreaView>
);
}
export default App;