Skip to content

Commit 9a841ea

Browse files
RMET-3699 Local Notifications - Fix notification not showing when app is on the foreground on Android (#34)
* fix: deliver notification if 'foreground' option is 'true' Context: If the app is in the foreground, and the 'foreground' option is 'true', we want to deliver the notification References: https://outsystemsrd.atlassian.net/browse/RMET-3699 * chore: update changelog and set plugin to version `0.9.13 References: https://outsystemsrd.atlassian.net/browse/RMET-3699 * refactor: refactor code for better readability References: https://outsystemsrd.atlassian.net/browse/RMET-3699
1 parent bcd8c39 commit 9a841ea

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Please also read the [Upgrade Guide](https://github.com/katzer/cordova-plugin-lo
55

66
#### Unreleased
77

8+
#### Version 0.9.13 (07.10.2024)
9+
### 07-10-2024
10+
- Android: Deliver notifications while app is in foreground if `foreground` option is `true`. [RMET-3699](https://outsystemsrd.atlassian.net/browse/RMET-3699)
11+
812
#### Version 0.9.12 (27.09.2023)
913
### 12-09-2023
1014
- Android: Make PendingIntents immutable for Android 14 [RMET-2666](https://outsystemsrd.atlassian.net/browse/RMET-2666)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-local-notification",
3-
"version": "0.9.12",
3+
"version": "0.9.13",
44
"description": "Schedules and queries for local notifications",
55
"cordova": {
66
"id": "cordova-plugin-local-notification",

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2525
xmlns:android="http://schemas.android.com/apk/res/android"
2626
id="cordova-plugin-local-notification"
27-
version="0.9.12">
27+
version="0.9.13">
2828

2929
<name>LocalNotification</name>
3030

src/android/notification/Notification.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,11 @@ private void cancelScheduledAlarms() {
385385
* Present the local notification to user.
386386
*/
387387
public void show() {
388-
// Don't show notification if the application is in foreground
389-
if(applicationState == null || applicationState.equalsIgnoreCase("foreground")) return;
388+
// Don't show notification if the application is in foreground and foreground option is false
389+
boolean showEvenInForeground = getOptions().getDict().optBoolean("foreground", false);
390+
391+
if (applicationState == null || (applicationState.equalsIgnoreCase("foreground") && !showEvenInForeground))
392+
return;
390393

391394
if (builder == null) return;
392395

0 commit comments

Comments
 (0)