-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
78 lines (69 loc) · 2.06 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
import React, {Component} from 'react';
import EStyleSheet from 'react-native-extended-stylesheet';
/**
* OneSignal
*/
import OneSignal from 'react-native-onesignal';
/**
* Codepush
*/
import codePush from 'react-native-code-push';
//@colors&fonts
import colors from './assets/styles/colors';
import fonts from './assets/styles/fonts';
/**
* @redux
*/
import {Provider} from 'react-redux';
import {PersistGate} from 'redux-persist/lib/integration/react';
import {persistor, store} from './store';
//i18n
import i18n from 'react-native-i18n';
import Navigator from './navigation/Navigator';
/** Disabled console warnings */
console.disableYellowBox = true;
class App extends Component {
constructor() {
super();
i18n.locale = 'tr'; // manually set language
EStyleSheet.build({
...colors,
...fonts,
});
OneSignal.init('98036549-9d8f-40fd-abdf-05fc18d89f2c');
OneSignal.addEventListener('received', this.onReceived);
OneSignal.addEventListener('opened', this.onOpened);
OneSignal.addEventListener('ids', this.onIds);
OneSignal.configure(); // triggers the ids event
}
componentWillUnmount() {
OneSignal.removeEventListener('received', this.onReceived);
OneSignal.removeEventListener('opened', this.onOpened);
OneSignal.removeEventListener('ids', this.onIds);
}
onReceived(notification) {
console.log('Notification received: ', notification);
}
onOpened(openResult) {
console.log('Message: ', openResult.notification.payload.body);
console.log('Data: ', openResult.notification.payload.additionalData);
console.log('isActive: ', openResult.notification.isAppInFocus);
console.log('openResult: ', openResult);
}
onIds(device) {
console.log('Device info: ', device);
}
render() {
return (
<Provider store={store}>
<PersistGate loading={false} persistor={persistor}>
<Navigator />
</PersistGate>
</Provider>
);
}
}
const codePushOptions = {
checkFrequency: codePush.CheckFrequency.ON_APP_START,
};
export default codePush(codePushOptions)(App);