-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.android.js
58 lines (47 loc) · 1.61 KB
/
index.android.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
'use strict';
var React = require('react-native');
var {
AppRegistry,
DeviceEventEmitter,
} = React;
var AppContainer = require('./components/AppContainer.js');
var PlainLog = require('./PlainLog.js');
var P = new PlainLog("AppContainerAndroid");
var SessionActions = require('./actions/SessionActions.js');
var ParsePush = require('./ParsePush');
class AppContainerAndroid extends AppContainer {
constructor(){
super();
this.componentDidMount = this.componentDidMount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
this.onNotification = this.onNotification.bind(this);
}
componentDidMount() {
super.componentDidMount();
ParsePush.addEventListener(ParsePush.REGISTER, this.onRegister);
DeviceEventEmitter.addListener(ParsePush.NOTIFICATION, this.onNotification);
P.log("componentDidMount", "MOUNTS");
}
componentWillUnmount() {
super.componentWillUnmount();
ParsePush.removeEventListener(ParsePush.REGISTER);
DeviceEventEmitter.removeAllListeners(ParsePush.NOTIFICATION);
P.log("componentWillUnmount", "UNMOUNTS");
}
onNotification(event){
var isApplicationActive = event["isActive"];
var data = JSON.parse(event["data"]);
P.log("onNotification", isApplicationActive);
P.log("onNotification", data);
if (isApplicationActive == ParsePush.ACTIVE) {
this.updateMessageCount();
}
else {
if (data["uri"]){
P.log("onNotification", "Follow URI " + data["uri"]);
SessionActions.updateUri(data["uri"]);
}
}
}
}
AppRegistry.registerComponent('plainX', () => AppContainerAndroid);