Skip to content
This repository was archived by the owner on Sep 24, 2021. It is now read-only.

Commit bb122f3

Browse files
authored
fix(android: stop foreground service fix (#275)
1 parent 968aa86 commit bb122f3

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

android/src/main/java/io/invertase/notifee/NotifeeApiModule.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ public void openPowerManagerSettings(Promise promise) {
235235
getCurrentActivity(), (e, avoid) -> NotifeeReactUtils.promiseResolver(promise, e));
236236
}
237237

238+
@ReactMethod
239+
public void stopForegroundService(Promise promise) {
240+
Notifee.getInstance()
241+
.stopForegroundService((e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
242+
}
243+
238244
@NonNull
239245
@Override
240246
public String getName() {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@notifee/react-native",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"author": "Invertase <[email protected]> (http://invertase.io)",
55
"description": "Notifee - a feature rich notifications library for React Native.",
66
"main": "dist/index.js",

src/NotifeeApiModule.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ if (isAndroid) {
5151
);
5252
return (): Promise<void> => Promise.resolve();
5353
}
54+
5455
return ({ notification }): Promise<void> => registeredForegroundServiceTask(notification);
5556
});
5657
}
@@ -555,4 +556,11 @@ export default class NotifeeApiModule extends NotifeeNativeModule implements Mod
555556
}
556557
return this.native.openPowerManagerSettings();
557558
};
559+
560+
public stopForegroundService = (): Promise<void> => {
561+
if (isIOS) {
562+
return Promise.resolve();
563+
}
564+
return this.native.stopForegroundService();
565+
};
558566
}

src/types/Module.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,14 @@ export interface Module {
359359
*/
360360
registerForegroundService(task: ForegroundServiceTask): void;
361361

362+
/**
363+
* Call this to stop the foreground service that is running
364+
*
365+
* @platform android
366+
*
367+
*/
368+
stopForegroundService(): Promise<void>;
369+
362370
/**
363371
* Request specific notification permissions for your application on the current device.
364372
*

0 commit comments

Comments
 (0)