-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReactNativeWorkManager.ts
More file actions
41 lines (36 loc) · 997 Bytes
/
ReactNativeWorkManager.ts
File metadata and controls
41 lines (36 loc) · 997 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
32
33
34
35
36
37
38
39
40
41
import { NativeModules } from 'react-native';
import { ScheduleParams } from './types';
const { SchedulingMaster } = NativeModules;
function scheduleJob(params: ScheduleParams): Promise<string> {
return new Promise((resolve, _) => {
SchedulingMaster.setUpWorker(
params.uniqueName,
params.type,
params.initialDelay,
params.intervalDelayUnit,
params.repeatInterval,
params.intervalUnit,
params.notificationTitle,
params.notificationDesc,
params.notificationColor,
(id: string) => {
resolve(id);
},
);
});
}
function getWorkInfoById(jobId: string | undefined) {
if (jobId) {
SchedulingMaster.getWorkInfoById(jobId, (result: boolean) =>
console.log(result),
);
}
}
function cancelJobById(jobId: string | undefined) {
if (jobId) {
SchedulingMaster.cancelJobById(jobId, (result: boolean) =>
console.log(result),
);
}
}
export { scheduleJob, cancelJobById, getWorkInfoById };