-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
65 lines (55 loc) · 1.59 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
import React, {Component, Fragment} from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
import RootNavigator from "./src/Routes/rootNavigator";
import SplashScreen from './src/Screen/Splash'
import OneSignal from 'react-native-onesignal';
class App extends Component {
constructor(props) {
super(props)
this.state = {
iduser: '',
token: '',
view: <SplashScreen />
}
OneSignal.init("abeb2a58-2404-472b-a013-c3a1fa55acef");
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 (
<Fragment>
<StatusBar barStyle="#075e54" />
<SafeAreaView>
<RootNavigator />
</SafeAreaView>
</Fragment>
);
}
};
export default App;