@hxa-rn/react-native-background-actions 0.0.0-stage → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +177 -2
- package/harmony/background_actions/LICENSE +22 -0
- package/harmony/background_actions/NOTICE +33 -0
- package/harmony/background_actions/OAT.xml +38 -0
- package/harmony/background_actions/build-profile.json5 +16 -0
- package/harmony/background_actions/hvigorfile.ts +2 -0
- package/harmony/background_actions/index.ets +1 -0
- package/harmony/background_actions/oh-package.json5 +14 -0
- package/harmony/background_actions/src/main/cpp/BackgroundActionsPackage.h +26 -0
- package/harmony/background_actions/src/main/cpp/BackgroundActionsTimerModule.cpp +54 -0
- package/harmony/background_actions/src/main/cpp/BackgroundActionsTimerModule.h +35 -0
- package/harmony/background_actions/src/main/cpp/CMakeLists.txt +3 -0
- package/harmony/background_actions/src/main/cpp/bridge/CMakeLists.txt +8 -0
- package/harmony/background_actions/src/main/cpp/generated/RNBackgroundActions.cpp +30 -0
- package/harmony/background_actions/src/main/cpp/generated/RNBackgroundActions.h +21 -0
- package/harmony/background_actions/src/main/cpp/generated/RNOHGeneratedPackage.h +76 -0
- package/harmony/background_actions/src/main/ets/BackgroundActionsModule.ets +425 -0
- package/harmony/background_actions/src/main/ets/BackgroundActionsTurboModulesFactory.ets +9 -0
- package/harmony/background_actions/src/main/ets/generated/components/ts.ts +5 -0
- package/harmony/background_actions/src/main/ets/generated/index.ets +8 -0
- package/harmony/background_actions/src/main/ets/generated/ts.ts +9 -0
- package/harmony/background_actions/src/main/ets/generated/turboModules/RNBackgroundActions.ts +65 -0
- package/harmony/background_actions/src/main/ets/generated/turboModules/ts.ts +8 -0
- package/harmony/background_actions/src/main/module.json5 +13 -0
- package/harmony/background_actions/src/main/resources/base/element/string.json +8 -0
- package/harmony/background_actions/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/background_actions/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/background_actions.har +0 -0
- package/package.json +82 -4
- package/src/BackgroundTimers.ts +72 -0
- package/src/RNBackgroundActionsModule.ts +78 -0
- package/src/index.ts +131 -0
- package/src/specs/v1/.gitkeep +1 -0
- package/src/specs/v1/NativeRNBackgroundActionsSpec.ts +27 -0
- package/src/specs/v2/.gitkeep +1 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {DeviceEventEmitter} from 'react-native';
|
|
2
|
+
import RNBackgroundActions from './specs/v1/NativeRNBackgroundActionsSpec';
|
|
3
|
+
|
|
4
|
+
type Callback = (...args: any[]) => void;
|
|
5
|
+
type SetTimer = (callback: Callback, delay?: number, ...args: any[]) => number;
|
|
6
|
+
type ClearTimer = (id?: number) => void;
|
|
7
|
+
type TimerGlobals = {setTimeout: SetTimer; setInterval: SetTimer; clearTimeout: ClearTimer; clearInterval: ClearTimer};
|
|
8
|
+
// RNOH 0.72 Timing pauses with UI lifecycle. The native executor runs these
|
|
9
|
+
// timers without VSync, while the actual OS background grant remains in force.
|
|
10
|
+
class BackgroundTimers {
|
|
11
|
+
private active = false;
|
|
12
|
+
private nextId = -1;
|
|
13
|
+
private timers = new Map<number, {callback: Callback; args: any[]; repeats: boolean}>();
|
|
14
|
+
private subscription?: {remove(): void};
|
|
15
|
+
private globals = globalThis as unknown as TimerGlobals;
|
|
16
|
+
private original?: TimerGlobals;
|
|
17
|
+
private schedule(callback: Callback, delay: number | undefined, args: any[], repeats: boolean): number {
|
|
18
|
+
if (typeof callback !== 'function') throw new TypeError('timer callback must be a function');
|
|
19
|
+
const duration = Number(delay ?? 0);
|
|
20
|
+
const milliseconds = Number.isFinite(duration) && duration >= 0 && duration <= 2147483647 ? Math.floor(duration) : 0;
|
|
21
|
+
const id = this.nextId--;
|
|
22
|
+
this.timers.set(id, {callback, args, repeats});
|
|
23
|
+
try { RNBackgroundActions.scheduleTimer(id, milliseconds, repeats); }
|
|
24
|
+
catch (error) { this.timers.delete(id); throw error; }
|
|
25
|
+
return id;
|
|
26
|
+
}
|
|
27
|
+
private timeout: SetTimer = (callback, delay, ...args) => this.schedule(callback, delay, args, false);
|
|
28
|
+
private interval: SetTimer = (callback, delay, ...args) => this.schedule(callback, delay, args, true);
|
|
29
|
+
private clear: ClearTimer = id => {
|
|
30
|
+
if (typeof id === 'number' && id < 0) {
|
|
31
|
+
RNBackgroundActions.cancelTimer(id);
|
|
32
|
+
this.timers.delete(id);
|
|
33
|
+
this.restore();
|
|
34
|
+
} else { this.original?.clearTimeout(id); }
|
|
35
|
+
};
|
|
36
|
+
activate(): void {
|
|
37
|
+
this.active = true;
|
|
38
|
+
if (!this.original) {
|
|
39
|
+
this.original = {setTimeout: this.globals.setTimeout, setInterval: this.globals.setInterval,
|
|
40
|
+
clearTimeout: this.globals.clearTimeout, clearInterval: this.globals.clearInterval};
|
|
41
|
+
this.subscription = DeviceEventEmitter.addListener('backgroundActionsTimer', (id: number) => {
|
|
42
|
+
const timer = this.timers.get(id);
|
|
43
|
+
if (!timer) return;
|
|
44
|
+
if (!timer.repeats) this.clear(id);
|
|
45
|
+
timer.callback(...timer.args);
|
|
46
|
+
});
|
|
47
|
+
this.globals.clearTimeout = this.clear;
|
|
48
|
+
this.globals.clearInterval = this.clear;
|
|
49
|
+
}
|
|
50
|
+
this.globals.setTimeout = this.timeout;
|
|
51
|
+
this.globals.setInterval = this.interval;
|
|
52
|
+
}
|
|
53
|
+
deactivate(): void {
|
|
54
|
+
this.active = false;
|
|
55
|
+
if (this.original) {
|
|
56
|
+
if (this.globals.setTimeout === this.timeout) this.globals.setTimeout = this.original.setTimeout;
|
|
57
|
+
if (this.globals.setInterval === this.interval) this.globals.setInterval = this.original.setInterval;
|
|
58
|
+
}
|
|
59
|
+
// Pending callbacks keep their handles and can still be cleared after stop.
|
|
60
|
+
// They do not renew any OS background grant.
|
|
61
|
+
this.restore();
|
|
62
|
+
}
|
|
63
|
+
private restore(): void {
|
|
64
|
+
if (this.active || this.timers.size || !this.original) return;
|
|
65
|
+
if (this.globals.clearTimeout === this.clear) this.globals.clearTimeout = this.original.clearTimeout;
|
|
66
|
+
if (this.globals.clearInterval === this.clear) this.globals.clearInterval = this.original.clearInterval;
|
|
67
|
+
this.subscription?.remove();
|
|
68
|
+
this.subscription = undefined;
|
|
69
|
+
this.original = undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export const backgroundTimers = new BackgroundTimers();
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {NativeEventEmitter} from 'react-native';
|
|
2
|
+
import NativeRNBackgroundActions from './specs/v1/NativeRNBackgroundActionsSpec';
|
|
3
|
+
|
|
4
|
+
const RNBackgroundActions: typeof NativeRNBackgroundActions = {
|
|
5
|
+
start: options => NativeRNBackgroundActions.start(options),
|
|
6
|
+
stop: () => NativeRNBackgroundActions.stop(),
|
|
7
|
+
updateNotification: options => NativeRNBackgroundActions.updateNotification(options),
|
|
8
|
+
isRunning: () => NativeRNBackgroundActions.isRunning(),
|
|
9
|
+
getStatus: () => NativeRNBackgroundActions.getStatus(),
|
|
10
|
+
requestNotifications: () => NativeRNBackgroundActions.requestNotifications(),
|
|
11
|
+
scheduleTimer(id, delay, repeats): void { NativeRNBackgroundActions.scheduleTimer(id, delay, repeats); },
|
|
12
|
+
cancelTimer(id): void { NativeRNBackgroundActions.cancelTimer(id); },
|
|
13
|
+
addListener(eventName): void { NativeRNBackgroundActions.addListener(eventName); },
|
|
14
|
+
removeListeners(count): void { NativeRNBackgroundActions.removeListeners(count); },
|
|
15
|
+
};
|
|
16
|
+
type Listener = (...args: any[]) => void;
|
|
17
|
+
export class BackgroundEventSubscription {
|
|
18
|
+
removed = false;
|
|
19
|
+
once = false;
|
|
20
|
+
native?: {remove(): void};
|
|
21
|
+
constructor(readonly emitter: BackgroundNativeEventEmitter, readonly eventType: string,
|
|
22
|
+
readonly listener: Listener, readonly context?: unknown) {}
|
|
23
|
+
remove(): void {
|
|
24
|
+
if (this.removed) return;
|
|
25
|
+
this.removed = true;
|
|
26
|
+
this.native?.remove();
|
|
27
|
+
this.emitter.forget(this);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Preserve the old public NativeEventEmitter surface on the RN 0.72 baseline.
|
|
31
|
+
// Each subscription still registers with the real native bridge.
|
|
32
|
+
class BackgroundNativeEventEmitter {
|
|
33
|
+
private native = new NativeEventEmitter(RNBackgroundActions);
|
|
34
|
+
private subscriptions: BackgroundEventSubscription[] = [];
|
|
35
|
+
private current?: BackgroundEventSubscription;
|
|
36
|
+
addListener(eventType: string, listener: Listener, context?: unknown): BackgroundEventSubscription {
|
|
37
|
+
if (typeof listener !== 'function') throw new TypeError('listener must be a function');
|
|
38
|
+
const subscription = new BackgroundEventSubscription(this, eventType, listener, context);
|
|
39
|
+
subscription.native = this.native.addListener(eventType, (...args: any[]) => {
|
|
40
|
+
if (subscription.removed) return;
|
|
41
|
+
if (subscription.once) subscription.remove();
|
|
42
|
+
const previous = this.current;
|
|
43
|
+
this.current = subscription;
|
|
44
|
+
try { listener.apply(context, args); } finally { this.current = previous; }
|
|
45
|
+
});
|
|
46
|
+
this.subscriptions.push(subscription);
|
|
47
|
+
return subscription;
|
|
48
|
+
}
|
|
49
|
+
once(eventType: string, listener: Listener, context?: unknown): BackgroundEventSubscription {
|
|
50
|
+
if (typeof listener !== 'function') throw new TypeError('listener must be a function');
|
|
51
|
+
const subscription = this.addListener(eventType, listener, context);
|
|
52
|
+
subscription.once = true;
|
|
53
|
+
return subscription;
|
|
54
|
+
}
|
|
55
|
+
emit(eventType: string, ...args: any[]): void { this.native.emit(eventType, ...args); }
|
|
56
|
+
listeners(eventType: string): BackgroundEventSubscription[] {
|
|
57
|
+
if (!eventType) throw new TypeError('eventType is required');
|
|
58
|
+
return this.subscriptions.filter(subscription => subscription.eventType === eventType && !subscription.removed);
|
|
59
|
+
}
|
|
60
|
+
listenerCount(eventType: string): number { return this.listeners(eventType).length; }
|
|
61
|
+
removeListener(eventType: string, listener: Listener): void {
|
|
62
|
+
this.listeners(eventType).filter(subscription => subscription.listener === listener).forEach(subscription => subscription.remove());
|
|
63
|
+
}
|
|
64
|
+
removeAllListeners(eventType: string): void { this.listeners(eventType).forEach(subscription => subscription.remove()); }
|
|
65
|
+
removeSubscription(subscription: BackgroundEventSubscription): void {
|
|
66
|
+
if (!subscription || subscription.emitter !== this) throw new Error('Subscription belongs to a different emitter');
|
|
67
|
+
subscription.remove();
|
|
68
|
+
}
|
|
69
|
+
removeCurrentListener(): void {
|
|
70
|
+
if (!this.current) throw new Error('removeCurrentListener must be called during dispatch');
|
|
71
|
+
this.current.remove();
|
|
72
|
+
}
|
|
73
|
+
forget(subscription: BackgroundEventSubscription): void {
|
|
74
|
+
this.subscriptions = this.subscriptions.filter(item => item !== subscription);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const nativeEventEmitter = new BackgroundNativeEventEmitter();
|
|
78
|
+
export {RNBackgroundActions, nativeEventEmitter};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// Copyright (c) 2026 hxa-rn
|
|
2
|
+
import {Platform as RNPlatform, AppRegistry} from 'react-native';
|
|
3
|
+
import EventEmitter from 'eventemitter3';
|
|
4
|
+
import {backgroundTimers} from './BackgroundTimers';
|
|
5
|
+
import {RNBackgroundActions, nativeEventEmitter, BackgroundEventSubscription} from './RNBackgroundActionsModule';
|
|
6
|
+
import type {NativeOptions, TaskIcon, ProgressBar} from './specs/v1/NativeRNBackgroundActionsSpec';
|
|
7
|
+
const Platform: {OS: string} = RNPlatform;
|
|
8
|
+
export type ForegroundServiceType = 'dataSync' | 'mediaPlayback' | 'phoneCall' | 'location' |
|
|
9
|
+
'connectedDevice' | 'mediaProjection' | 'camera' | 'microphone' | 'health' |
|
|
10
|
+
'remoteMessaging' | 'systemExempted' | 'shortService' | 'specialUse';
|
|
11
|
+
export type BackgroundTaskOptions = {
|
|
12
|
+
taskName: string; taskTitle: string; taskDesc: string; taskIcon: TaskIcon;
|
|
13
|
+
color?: string; linkingURI?: string; progressBar?: ProgressBar;
|
|
14
|
+
foregroundServiceType?: ForegroundServiceType[];
|
|
15
|
+
harmonyBackgroundModes?: Array<'bluetoothInteraction' | 'multiDeviceConnection' | 'audioRecording' | 'audioPlayback'>;
|
|
16
|
+
};
|
|
17
|
+
type RuntimeOptions = NativeOptions & {generation: number};
|
|
18
|
+
export type NotificationPatch = Partial<Omit<BackgroundTaskOptions, 'taskName' | 'foregroundServiceType' | 'harmonyBackgroundModes'>>;
|
|
19
|
+
export type TaskFailure = {code: string; message: string; generation: number};
|
|
20
|
+
function invalid(message: string): Error { return new Error(`E_INVALID_OPTIONS: ${message}`); }
|
|
21
|
+
class BackgroundServer extends EventEmitter {
|
|
22
|
+
private generation = 0;
|
|
23
|
+
private stopVersion = 0;
|
|
24
|
+
private tail: Promise<void> = Promise.resolve();
|
|
25
|
+
private options?: RuntimeOptions;
|
|
26
|
+
private subscription?: BackgroundEventSubscription;
|
|
27
|
+
private enqueue<T>(operation: () => Promise<T>): Promise<T> {
|
|
28
|
+
const result = this.tail.then(operation);
|
|
29
|
+
this.tail = result.then(() => undefined, () => undefined);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
private subscribe(): void {
|
|
33
|
+
if (this.subscription && !this.subscription.removed) return;
|
|
34
|
+
this.subscription = nativeEventEmitter.addListener('expiration', (event: {generation: number}) => {
|
|
35
|
+
if (event?.generation !== this.options?.generation) return;
|
|
36
|
+
this.options = undefined;
|
|
37
|
+
backgroundTimers.deactivate();
|
|
38
|
+
this.unsubscribe();
|
|
39
|
+
this.emit('expiration');
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
private unsubscribe(): void { this.subscription?.remove(); this.subscription = undefined; }
|
|
43
|
+
private normalize(options: BackgroundTaskOptions, generation: number): RuntimeOptions {
|
|
44
|
+
if (!options || typeof options.taskName !== 'string' || !options.taskName.trim()) throw invalid('taskName must be nonempty');
|
|
45
|
+
if (typeof options.taskTitle !== 'string' || typeof options.taskDesc !== 'string') throw invalid('title/description must be strings (empty allowed)');
|
|
46
|
+
const icon = options.taskIcon;
|
|
47
|
+
if (!icon || typeof icon.name !== 'string' || !icon.name || typeof icon.type !== 'string') throw invalid('taskIcon is required');
|
|
48
|
+
if (!['mipmap', 'drawable', 'media'].includes(icon.type)) throw invalid('icon.type must be mipmap/drawable/media');
|
|
49
|
+
if (icon.package !== undefined && typeof icon.package !== 'string') throw invalid('icon.package must be string');
|
|
50
|
+
const types = options.foregroundServiceType;
|
|
51
|
+
if (options.harmonyBackgroundModes !== undefined && (!Array.isArray(options.harmonyBackgroundModes) || options.harmonyBackgroundModes.some(m => typeof m !== 'string'))) throw invalid('harmonyBackgroundModes must be a string array');
|
|
52
|
+
if (types !== undefined && (!Array.isArray(types) || types.some(t => typeof t !== 'string'))) throw invalid('foregroundServiceType must be a string array');
|
|
53
|
+
if (options.linkingURI !== undefined && (typeof options.linkingURI !== 'string' || !/^[a-zA-Z][a-zA-Z0-9+.-]*:\S+$/.test(options.linkingURI))) throw invalid('linkingURI must be an absolute URI');
|
|
54
|
+
const progress = options.progressBar;
|
|
55
|
+
if (progress != null && (typeof progress !== 'object' || Array.isArray(progress))) throw invalid('progressBar must be an object');
|
|
56
|
+
if (progress && (!Number.isFinite(progress.max) || !Number.isFinite(progress.value) || Math.floor(progress.max) <= 0 || Math.floor(progress.value) < 0 || Math.floor(progress.value) > Math.floor(progress.max) || (progress.indeterminate !== undefined && typeof progress.indeterminate !== 'boolean'))) throw invalid('progress requires max > 0 and 0 <= value <= max');
|
|
57
|
+
return {taskName: options.taskName, taskTitle: options.taskTitle, taskDesc: options.taskDesc,
|
|
58
|
+
taskIcon: {...icon}, color: typeof options.color === 'string' ? options.color : '#ffffff',
|
|
59
|
+
linkingURI: options.linkingURI, progressBar: progress ? {...progress} : undefined,
|
|
60
|
+
foregroundServiceType: types ? [...types] : undefined, harmonyBackgroundModes: options.harmonyBackgroundModes ? [...options.harmonyBackgroundModes] : undefined, generation};
|
|
61
|
+
}
|
|
62
|
+
isRunning(): boolean { return RNBackgroundActions.isRunning(); }
|
|
63
|
+
start<T>(task: (parameters?: T) => Promise<void>, options: BackgroundTaskOptions & {parameters?: T}): Promise<void> {
|
|
64
|
+
if (typeof task !== 'function') return Promise.reject(invalid('task must be a function'));
|
|
65
|
+
const generation = this.generation + 1;
|
|
66
|
+
let normalized: RuntimeOptions;
|
|
67
|
+
try { normalized = this.normalize(options, generation); } catch (error) { return Promise.reject(error); }
|
|
68
|
+
this.generation = generation;
|
|
69
|
+
const stopVersion = this.stopVersion;
|
|
70
|
+
return this.enqueue(async () => {
|
|
71
|
+
const previous = this.options;
|
|
72
|
+
this.subscribe();
|
|
73
|
+
try { await RNBackgroundActions.start(normalized); }
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (previous && this.isRunning()) {
|
|
76
|
+
this.options = previous;
|
|
77
|
+
} else { this.options = undefined; backgroundTimers.deactivate(); this.unsubscribe(); }
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
this.options = normalized;
|
|
81
|
+
if (stopVersion !== this.stopVersion) return;
|
|
82
|
+
if (Platform.OS === 'harmony') backgroundTimers.activate();
|
|
83
|
+
const execute = async () => {
|
|
84
|
+
try {
|
|
85
|
+
if (stopVersion !== this.stopVersion || !this.isRunning()) return;
|
|
86
|
+
const result = task(options.parameters);
|
|
87
|
+
if (!result || typeof result.then !== 'function') throw invalid('task must return Promise<void>');
|
|
88
|
+
await result;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
const failure: TaskFailure = {code: 'E_TASK', message: String(error), generation};
|
|
91
|
+
this.emit('taskError', failure);
|
|
92
|
+
} finally {
|
|
93
|
+
try {
|
|
94
|
+
await this.enqueue(async () => {
|
|
95
|
+
if (this.options?.generation !== generation) return;
|
|
96
|
+
await RNBackgroundActions.stop();
|
|
97
|
+
this.options = undefined;
|
|
98
|
+
backgroundTimers.deactivate();
|
|
99
|
+
this.unsubscribe();
|
|
100
|
+
});
|
|
101
|
+
} catch (error) {
|
|
102
|
+
this.emit('taskError', {code: 'E_CLEANUP', message: String(error), generation});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
if (Platform.OS === 'harmony') { void execute(); }
|
|
107
|
+
else if (Platform.OS === 'android') { AppRegistry.registerHeadlessTask(normalized.taskName, () => execute); }
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
stop(): Promise<void> {
|
|
111
|
+
++this.stopVersion;
|
|
112
|
+
return this.enqueue(async () => {
|
|
113
|
+
await RNBackgroundActions.stop();
|
|
114
|
+
this.options = undefined;
|
|
115
|
+
backgroundTimers.deactivate();
|
|
116
|
+
this.unsubscribe();
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
updateNotification(patch: NotificationPatch): Promise<void> {
|
|
120
|
+
return this.enqueue(async () => {
|
|
121
|
+
if (!this.isRunning() || !this.options) throw new Error('E_NOT_RUNNING: A BackgroundAction must be running before updating the notification');
|
|
122
|
+
const candidate = this.normalize({...this.options, ...patch} as BackgroundTaskOptions, this.options.generation);
|
|
123
|
+
await RNBackgroundActions.updateNotification(candidate);
|
|
124
|
+
if (this.options?.generation !== candidate.generation || !this.isRunning()) {
|
|
125
|
+
throw new Error('E_TASK_ENDED: Task ended during notification update');
|
|
126
|
+
}
|
|
127
|
+
this.options = candidate;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export default new BackgroundServer();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# This file ensures the directory is tracked by Git even if other files are removed
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
|
|
2
|
+
import {TurboModuleRegistry} from 'react-native';
|
|
3
|
+
export type TaskIcon = {name: string; type: string; package?: string};
|
|
4
|
+
export type ProgressBar = {max: number; value: number; indeterminate?: boolean};
|
|
5
|
+
export type NativeOptions = {
|
|
6
|
+
taskName: string; taskTitle: string; taskDesc: string; taskIcon: TaskIcon;
|
|
7
|
+
color?: string; linkingURI?: string; progressBar?: ProgressBar;
|
|
8
|
+
foregroundServiceType?: Array<string>; harmonyBackgroundModes?: Array<string>; generation?: number;
|
|
9
|
+
};
|
|
10
|
+
export type TaskStatus = {
|
|
11
|
+
running: boolean; mode: string; requestId: number; notificationId: number;
|
|
12
|
+
actualDelayTime: number; cancelEventsSupported: boolean;
|
|
13
|
+
lastErrorCode: string; lastErrorMessage: string;
|
|
14
|
+
};
|
|
15
|
+
export interface Spec extends TurboModule {
|
|
16
|
+
start(options: NativeOptions): Promise<void>;
|
|
17
|
+
stop(): Promise<void>;
|
|
18
|
+
updateNotification(options: NativeOptions): Promise<void>;
|
|
19
|
+
isRunning(): boolean;
|
|
20
|
+
getStatus(): Promise<TaskStatus>;
|
|
21
|
+
requestNotifications(): Promise<boolean>;
|
|
22
|
+
scheduleTimer(id: number, delay: number, repeats: boolean): void;
|
|
23
|
+
cancelTimer(id: number): void;
|
|
24
|
+
addListener(eventName: string): void;
|
|
25
|
+
removeListeners(count: number): void;
|
|
26
|
+
}
|
|
27
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('RNBackgroundActions');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# This file ensures the directory is tracked by Git
|