Commit aacd804f authored by Sebastián Katzer's avatar Sebastián Katzer
Browse files

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

parent d3367090
Loading
Loading
Loading
Loading
+1 −0
Changes for README.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -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.
- [enhancement:] `cancel` & `cancelAll` remove the notification(s) from notification center as well 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)
- Added WP8 support<br>
+9 −0
Changes for src/android/LocalNotification.java: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -193,6 +193,15 @@ public class LocalNotification extends CordovaPlugin {
        editor.commit();
    }

    /**
     * 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.
     */
+3 −0
Changes for src/android/Receiver.java: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -54,6 +54,9 @@ public class Receiver extends BroadcastReceiver {
        this.context = context;
        this.options = options;

        // The context may got lost if the app was not running before
        LocalNotification.setContext(context);

        if (options.getInterval() == 0) {
            LocalNotification.unpersist(options.getId());
        } else if (isFirstAlarmInFuture()) {
+2 −0
Changes for src/android/Restore.java: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ public class Restore extends BroadcastReceiver {
                JSONArray args  = new JSONArray(alarms.getString(alarmId, ""));
                Options options = new Options(context).parse(args.getJSONObject(0));

                // The context got lost after reboot
                LocalNotification.setContext(context);
                LocalNotification.add(options);

            } catch (JSONException e) {}