Commit aacd804f by Sebastián Katzer

Bugfix: Android notification is shown when the app is not running.

parent d3367090
...@@ -46,6 +46,7 @@ cordova plugin rm de.appplant.cordova.plugin.local-notifications ...@@ -46,6 +46,7 @@ cordova plugin rm de.appplant.cordova.plugin.local-notifications
- [bugfix:] `cancel` on iOS did not work do to wrong param type. - [bugfix:] `cancel` on iOS did not work do to wrong param type.
- [enhancement:] `cancel` & `cancelAll` remove the notification(s) from notification center as well on Android. - [enhancement:] `cancel` & `cancelAll` remove the notification(s) from notification center as well on Android.
- [bugfix:] Missing background callback on Android. - [bugfix:] Missing background callback on Android.
- [bugfix:] Android notification is not shown when the app is not running.
#### Version 0.6.0 (16.11.2013) #### Version 0.6.0 (16.11.2013)
- Added WP8 support<br> - Added WP8 support<br>
......
...@@ -194,6 +194,15 @@ public class LocalNotification extends CordovaPlugin { ...@@ -194,6 +194,15 @@ public class LocalNotification extends CordovaPlugin {
} }
/** /**
* Set the application context if not already set.
*/
public static void setContext (Context context) {
if (this.context == null) {
this.context = context;
}
}
/**
* The Local storage for the application. * The Local storage for the application.
*/ */
public static SharedPreferences getSharedPreferences () { public static SharedPreferences getSharedPreferences () {
......
...@@ -54,6 +54,9 @@ public class Receiver extends BroadcastReceiver { ...@@ -54,6 +54,9 @@ public class Receiver extends BroadcastReceiver {
this.context = context; this.context = context;
this.options = options; this.options = options;
// The context may got lost if the app was not running before
LocalNotification.setContext(context);
if (options.getInterval() == 0) { if (options.getInterval() == 0) {
LocalNotification.unpersist(options.getId()); LocalNotification.unpersist(options.getId());
} else if (isFirstAlarmInFuture()) { } else if (isFirstAlarmInFuture()) {
......
...@@ -40,6 +40,8 @@ public class Restore extends BroadcastReceiver { ...@@ -40,6 +40,8 @@ public class Restore extends BroadcastReceiver {
JSONArray args = new JSONArray(alarms.getString(alarmId, "")); JSONArray args = new JSONArray(alarms.getString(alarmId, ""));
Options options = new Options(context).parse(args.getJSONObject(0)); Options options = new Options(context).parse(args.getJSONObject(0));
// The context got lost after reboot
LocalNotification.setContext(context);
LocalNotification.add(options); LocalNotification.add(options);
} catch (JSONException e) {} } catch (JSONException e) {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment