-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (22 loc) · 754 Bytes
/
index.js
File metadata and controls
27 lines (22 loc) · 754 Bytes
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
/**
* Created by Tong on 2016/8/16.
*/
import {NativeModules, DeviceEventEmitter} from 'react-native';
import Rx from 'rx';
import _ from 'lodash';
const LeanCloudPushNative = NativeModules.LeanCloudPush;
export const observable = new Rx.Subject();
export const getInstallationId = function () {
return LeanCloudPushNative.getInstallationId();
};
export const getInitialNotification = function () {
return LeanCloudPushNative.getInitialNotification();
}
export const initialize = _.once(function () {
DeviceEventEmitter.addListener(LeanCloudPushNative.ON_RECEIVE, (res) => {
observable.onNext(res);
});
DeviceEventEmitter.addListener(LeanCloudPushNative.ON_ERROR, (res) => {
observable.onError(res);
});
});