From fafa242d8327cae0a18659a99877f5a209dd339a Mon Sep 17 00:00:00 2001 From: Auke Swen Date: Wed, 22 Sep 2021 16:32:50 +0200 Subject: [PATCH 1/5] Delete Alarms when intent is deleted --- src/android/notification/Notification.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/android/notification/Notification.java b/src/android/notification/Notification.java index 372cfb07f..e8dabb39a 100644 --- a/src/android/notification/Notification.java +++ b/src/android/notification/Notification.java @@ -45,6 +45,7 @@ import java.util.Set; import java.util.Timer; import java.util.TimerTask; +import de.appplant.cordova.plugin.localnotification.TriggerReceiver; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -97,6 +98,9 @@ public enum Type { // Builder with full configuration private final NotificationCompat.Builder builder; + // Receiver to handle the trigger event + private Class receiver = TriggerReceiver.class; + /** * Constructor * @@ -184,6 +188,8 @@ void schedule(Request request, Class receiver) { List> intents = new ArrayList>(); Set ids = new ArraySet(); AlarmManager mgr = getAlarmMgr(); + + this.receiver = receiver; cancelScheduledAlarms(); @@ -311,7 +317,8 @@ private void cancelScheduledAlarms() { return; for (String action : actions) { - Intent intent = new Intent(action); + Intent intent = new Intent(context, this.receiver) + .setAction(action); PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, 0); @@ -348,6 +355,8 @@ void update (JSONObject updates, Class receiver) { mergeJSONObjects(updates); persist(null); + this.receiver = receiver; + if (getType() != Type.TRIGGERED) return; From 9b6748a3abbdb112f912dd896d58f34e485dcc9a Mon Sep 17 00:00:00 2001 From: Auke Swen Date: Thu, 23 Sep 2021 09:32:37 +0200 Subject: [PATCH 2/5] Bump version number --- plugin.xml | 2 +- www/local-notification.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.xml b/plugin.xml index d3be11c24..25ee48281 100644 --- a/plugin.xml +++ b/plugin.xml @@ -24,7 +24,7 @@ + version="0.9.0-beta.5"> LocalNotification diff --git a/www/local-notification.js b/www/local-notification.js index 7981f22eb..b48054df9 100644 --- a/www/local-notification.js +++ b/www/local-notification.js @@ -638,7 +638,7 @@ exports._mergeWithDefaults = function (options) { options.meta = { plugin: 'cordova-plugin-local-notification', - version: '0.9-beta.4' + version: '0.9-beta.5' }; return options; From 615995b9046500933a7936355608084962a69184 Mon Sep 17 00:00:00 2001 From: Auke Swen Date: Thu, 23 Sep 2021 09:33:34 +0200 Subject: [PATCH 3/5] Do not track new .DS_Store files --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ec65b086f..c1a6479db 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /src/windows/Microsoft.Toolkit.Uwp.Notifications.* /src/windows/**/.vs /src/windows/**/bin -/src/windows/**/obj \ No newline at end of file +/src/windows/**/obj +*.DS_Store \ No newline at end of file From 849064967d0d9c9d5abe35e81b432c4902b7a871 Mon Sep 17 00:00:00 2001 From: Auke Swen Date: Tue, 9 Nov 2021 14:35:34 +0100 Subject: [PATCH 4/5] update readme --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e9e32b86a..d0b9c6f03 100644 --- a/README.md +++ b/README.md @@ -451,7 +451,12 @@ cordova.plugins.notification.local.requestIgnoreBatteryOptimizations(function (g ``` The request method here will work one of two ways. -1. If you have the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission defined in the manifest, it will use ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS to explicitly ignore battery optimizations for this app. This is the best overall user experience, but the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission seems to be frowned upon and can get your app banned. This plugin does not have this permission in plugin.xml for this reason, so you will need to use the cordova-custom-config plugin to add it to your config.xml +1. If you have the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission defined in the manifest, it will use ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS to explicitly ignore battery optimizations for this app. This is the best overall user experience, but the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission seems to be frowned upon and can get your app banned. This plugin does not have this permission in plugin.xml for this reason, so you will need to use the cordova-custom-config plugin to add it to your config.xml. Alternatively, you can use the edit-config tag in the platform section of the config.xml. +```xml + + + +``` 2. If you do not have REQUEST_IGNORE_BATTERY_OPTIMIZATIONS requested, it will launch ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS to show a list of all applications. You will want to put some sort of instructions prior to this to walk the user through this. Also, this action doesn't exist on all Android devices (is missing on Samsung phones), which will make this method simply return false if it can't start the activity. From 9596ec87c2f67647d4656a0040b15b48dd24ada9 Mon Sep 17 00:00:00 2001 From: Auke Swen Date: Thu, 27 Jan 2022 11:34:16 +0100 Subject: [PATCH 5/5] update read me --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0b9c6f03..807e1715c 100644 --- a/README.md +++ b/README.md @@ -453,7 +453,7 @@ cordova.plugins.notification.local.requestIgnoreBatteryOptimizations(function (g The request method here will work one of two ways. 1. If you have the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission defined in the manifest, it will use ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS to explicitly ignore battery optimizations for this app. This is the best overall user experience, but the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission seems to be frowned upon and can get your app banned. This plugin does not have this permission in plugin.xml for this reason, so you will need to use the cordova-custom-config plugin to add it to your config.xml. Alternatively, you can use the edit-config tag in the platform section of the config.xml. ```xml - + ```