-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
87 lines (74 loc) · 2.24 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React from 'react'
import {
StatusBar,
} from 'react-native'
import { Provider } from 'react-redux'
import Store from './src/Redux/store'
import * as firebase from "firebase"
import Navigator from './src/Navigator'
import PushNotification from 'react-native-push-notification'
import {
API_KEY,
AUTH_DOMAIN,
DATABASE_URL,
STORAGE_BUCKET
} from 'react-native-dotenv'
const config = {
apiKey: API_KEY,
authDomain: AUTH_DOMAIN,
databaseURL: DATABASE_URL,
storageBucket: STORAGE_BUCKET
}
if (!firebase.apps.length) {
firebase.initializeApp(config)
}else{
firebase.app()
}
PushNotification.configure({
// (optional) Called when Token is generated (iOS and Android)
onRegister: function(token) {
console.log("TOKEN:", token);
},
// (required) Called when a remote or local notification is opened or received
onNotification: function(notification) {
console.log("NOTIFICATION:", notification);
// process the notification
PushNotification.localNotification({
/* iOS and Android properties */
title: notification.title, // (optional)
message: notification.body, // (required)
playSound: true, // (optional) default: true
repeatType: 'day', // (optional) Repeating interval. Check 'Repeating Notifications' section for more info.
actions: '["Yes", "No"]', // (Android only) See the doc for notification actions to know more
})
},
// ANDROID ONLY: GCM or FCM Sender ID (product_number) (optional - not required for local notifications, but is need to receive remote push notifications)
senderID: "55502078067",
// Should the initial notification be popped automatically
// default: true
popInitialNotification: true,
/**
* (optional) default: true
* - Specified if permissions (ios) and token (android and ios) will requested or not,
* - if not, you must call PushNotificationsHandler.requestPermissions() later
*/
requestPermissions: true
});
const App: () => React$Node = () => {
return (
<>
<Provider store={Store}>
<StatusBar barStyle="light-content" />
<Navigator />
</Provider>
</>
);
};
export default App;