-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (37 loc) · 1.48 KB
/
index.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
import { AppRegistry, UIManager } from 'react-native';
import { PushNotificationIOS, Platform } from 'react-native';
import PushNotification from 'react-native-push-notification';
import App from './App';
import Logger from './src/utils/logger';
import Device from './src/security/device';
import settings from './src/settings/index';
UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);
AppRegistry.registerComponent('reactnativepetapp', () => App);
settings
.then(({ gsmSenderId }) => (
PushNotification.configure({
onRegister: function onRegister({ token }) {
Logger.info('TOKEN', token);
Device.token = token;
},
onNotification: function onNotify(notification) {
Logger.info('NOTIFICATION', notification);
const {
msgTitle,
msgBody
} = notification;
PushNotification.localNotification({
title: msgTitle,
message: msgBody
});
if (Platform.OS === 'ios') {
notification.finish(PushNotificationIOS.FetchResult.NoData);
} else {
notification.finish();
}
},
senderID: gsmSenderId
})
))
.catch(error =>
Logger.error('Can not initialize push notification service due to error', error));