forked from voximplant/react-native-foreground-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
74 lines (62 loc) · 2.34 KB
/
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
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright (c) 2011-2019, Zingaya, Inc. All rights reserved.
*/
'use strict';
import { NativeModules } from 'react-native';
const ForegroundServiceModule = NativeModules.VIForegroundService;
/**
* @property {string} channelId - Notification channel id to display notification
* @property {number} id - Unique notification id
* @property {string} title - Notification title
* @property {string} text - Notification text
* @property {string} icon - Small icon name
* @property {number} [priority] - Priority of this notification. One of:
* 0 - PRIORITY_DEFAULT (by default),
* -1 - PRIORITY_LOW,
* -2 - PRIORITY_MIN,
* 1 - PRIORITY_HIGH,
* 2- PRIORITY_MAX
*/
const NotificationConfig = {
};
/**
* @property {string} id - Unique channel ID
* @property {string} name - Notification channel name
* @property {string} [description] - Notification channel description
* @property {number} [importance] - Notification channel importance. One of:
* 1 - 'min',
* 2 - 'low' (by default),
* 3 - 'default',
* 4 - 'high',
* 5 - 'max'.
* @property {boolean} [enableVibration] - Sets whether notification posted to this channel should vibrate. False by default.
*/
const NotificationChannelConfig = {
};
export default class VIForegroundService {
/**
* Create notification channel for foreground service
*
* @param {NotificationChannelConfig} channelConfig - Notification channel configuration
* @return Promise
*/
static async createNotificationChannel(channelConfig) {
return await ForegroundServiceModule.createNotificationChannel(channelConfig);
}
/**
* Start foreground service
* @param {NotificationConfig} notificationConfig - Notification config
* @return Promise
*/
static async startService(notificationConfig) {
return await ForegroundServiceModule.startService(notificationConfig);
}
/**
* Stop foreground service
*
* @return Promise
*/
static async stopService() {
return await ForegroundServiceModule.stopService();
}
}