forked from b8ne/react-native-pusher-push-notifications
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
31 lines (29 loc) · 942 Bytes
/
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
'use strict';
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
const { RNPusherPushNotifications } = NativeModules
const rnPusherPushNotificationsEmitter = new NativeEventEmitter(RNPusherPushNotifications)
export default {
setAppKey: (appKey) => {
RNPusherPushNotifications.setAppKey(appKey)
},
subscribe: (channel, onError, onSuccess) => {
if (Platform.OS === 'ios') {
RNPusherPushNotifications.subscribe(channel)
} else {
RNPusherPushNotifications.subscribe(channel, onError, onSuccess)
}
},
unsubscribe: (channel, onError, onSuccess) => {
if (Platform.OS === 'ios') {
RNPusherPushNotifications.unsubscribe(channel)
} else {
RNPusherPushNotifications.unsubscribe(channel, onError, onSuccess)
}
},
on: (eventName, callback) => {
rnPusherPushNotificationsEmitter.addListener(
eventName,
(payload) => callback(payload)
)
}
};