-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (25 loc) · 833 Bytes
/
index.js
File metadata and controls
31 lines (25 loc) · 833 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
28
29
30
31
import {NativeModules, DeviceEventEmitter} from 'react-native';
const eventsMap = {
notification: 'notificationReceived',
//installedApps: 'installedApps',
};
const NotificationModule = NativeModules.NotificationModule;
const Notification = {};
Notification.getPermissionStatus = () => {
return NotificationModule.getPermissionStatus();
}
Notification.requestPermission = () => {
return NotificationModule.requestPermission();
}
Notification.getInstalledApps = () => {
return NotificationModule.getInstalledApps();
}
Notification.on = (event, callback) => {
const nativeEvent = eventsMap[event];
if (!nativeEvent) {
throw new Error('Invalid event');
}
DeviceEventEmitter.removeAllListeners(nativeEvent);
return DeviceEventEmitter.addListener(nativeEvent, callback);
}
module.exports = Notification;