-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (31 loc) · 1.16 KB
/
index.js
File metadata and controls
40 lines (31 loc) · 1.16 KB
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
import { NativeModules, DeviceEventEmitter } from 'react-native'
const { RNPushyNotifications } = NativeModules
//Configure the notifications that will be created.
//Send an object (optional) to override the values in the defaultConfiguration.
async function configure() {
return await RNPushyNotifications.configure()
}
//Pass your topic: "my-topic". Should match: [a-zA-Z0-9-_.]+
async function subscribe(topic) {
return await RNPushyNotifications.subscribe(topic)
}
//Pass your topic: "my-topic". Should match: [a-zA-Z0-9-_.]+
async function unsubscribe(topic) {
return await RNPushyNotifications.unsubscribe(topic)
}
//Pass your topic: "my-topic". Should match: [a-zA-Z0-9-_.]+
async function toggleNotifications(enabled) {
return await RNPushyNotifications.toggleNotifications(enabled)
}
//This listener will catch incoming notification events.
const setNotificationReceivedListener = (onNotificationReceived) => {
return DeviceEventEmitter.addListener('NotificationReceived', onNotificationReceived)
}
const PushyNotifications = {
configure,
subscribe,
unsubscribe,
toggleNotifications,
setNotificationReceivedListener
}
export default PushyNotifications