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 diff --git a/README.md b/README.md index e9e32b86a..807e1715c 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. 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/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; 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;