Commit 33970e4c authored by Simon MacDonald's avatar Simon MacDonald
Browse files

Issue #67: Pushes being deleted from notification bar when cold start

parent 45af9530
Loading
Loading
Loading
Loading
+1 −0
Changes for README.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ Parameter | Description
`options.android.iconColor` | `String` Optional. Sets the background color of the small icon. [Supported Formats](http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String))
`options.android.sound` | `Boolean` Optional. If `true` it plays the sound specified in the push data or the default system sound. Default is `true`.
`options.android.vibrate` | `Boolean` Optional. If `true` the device vibrates on receipt of notification. Default is `true`.
`options.android.clearNotifications` | `Boolean` Optional. If `true` the app clears all pending notifications when it is closed. Default is `true`.
`options.ios` | `JSON Object` iOS specific initialization options.
`options.windows` | `JSON Object` Windows specific initialization options.

+3 −3
Changes for src/android/com/adobe/phonegap/push/GCMIntentService.java: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ public class GCMIntentService extends GCMBaseIntentService {
                .setContentIntent(contentIntent)
                .setAutoCancel(true);

        SharedPreferences prefs = context.getSharedPreferences("com.adobe.phonegap.push", Context.MODE_PRIVATE);
        SharedPreferences prefs = context.getSharedPreferences(PushPlugin.COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE);
        String localIcon = prefs.getString("icon", null);
        String localIconColor = prefs.getString("iconColor", null);
        boolean soundOption = prefs.getBoolean("sound", true);
@@ -329,14 +329,14 @@ public class GCMIntentService extends GCMBaseIntentService {
            try {
                iconColor = Color.parseColor(color);
            } catch (IllegalArgumentException e) {
                Log.e(LOG_TAG, "couldnt parse color from android options");
                Log.e(LOG_TAG, "couldn't parse color from android options");
            }
        }
        else if (localIconColor != null) {
            try {
                iconColor = Color.parseColor(localIconColor);
            } catch (IllegalArgumentException e) {
                Log.e(LOG_TAG, "couldnt parse color from android options");
                Log.e(LOG_TAG, "couldn't parse color from android options");
            }
        }
        if (iconColor != 0) {
+6 −1
Changes for src/android/com/adobe/phonegap/push/PushPlugin.java: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import org.json.JSONObject;
import java.util.Iterator;

public class PushPlugin extends CordovaPlugin {
    private static final String COM_ADOBE_PHONEGAP_PUSH = "com.adobe.phonegap.push";
    public static final String COM_ADOBE_PHONEGAP_PUSH = "com.adobe.phonegap.push";

    public static final String LOG_TAG = "PushPlugin";

@@ -89,6 +89,7 @@ public class PushPlugin extends CordovaPlugin {
                }
                editor.putBoolean("sound", jo.optBoolean("sound", true));
                editor.putBoolean("vibrate", jo.optBoolean("vibrate", true));
                editor.putBoolean("clearNotifications", jo.optBoolean("clearNotifications", true));
                editor.commit();
            }

@@ -151,9 +152,13 @@ public class PushPlugin extends CordovaPlugin {
    public void onPause(boolean multitasking) {
        super.onPause(multitasking);
        gForeground = false;

        SharedPreferences prefs = getApplicationContext().getSharedPreferences(PushPlugin.COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE);
        if (prefs.getBoolean("clearNotifications", true)) {
            final NotificationManager notificationManager = (NotificationManager) cordova.getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.cancelAll();
        }
    }

    @Override
    public void onResume(boolean multitasking) {