Skip to content

Commit d3e7ce7

Browse files
committed
Added optional ability to allow multiple notifications in android notification tray.
1 parent 209081f commit d3e7ce7

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

src/android/ParsePushConfigReader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public final class ParsePushConfigReader {
3333
// ParseClientKey is not required by parse server, but can be required by some environments
3434
private static final String parseClientKeyKey = "ParseClientKey";
3535

36-
3736
private List<String> supportedKeys = new ArrayList(Arrays.asList(parseAppIdKey, parseServerUrlKey));
3837
private Map<String, String> configs;
3938

src/android/ParsePushPluginReceiver.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import android.app.Notification;
1111
import android.app.NotificationManager;
1212

13+
import github.taivo.parsepushplugin.ParsePushConfigReader;
14+
import github.taivo.parsepushplugin.ParsePushConfigException;
15+
1316
import android.support.v4.app.NotificationCompat;
1417

1518
import android.net.Uri;
@@ -40,15 +43,24 @@ protected void onPushReceive(Context context, Intent intent) {
4043
// relay the push notification data to the javascript
4144
ParsePushPlugin.jsCallback( getPushData(intent) );
4245
} else {
43-
//
44-
// only create entry for notification tray if plugin/application is
45-
// not running in foreground.
46-
//
47-
// use tag + notification id=0 to limit the number of notifications on the tray
48-
// (older messages with the same tag and notification id will be replaced)
49-
NotificationManager notifManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
50-
notifManager.notify(getNotificationTag(context, intent), 0, getNotification(context, intent));
51-
46+
//
47+
// only create entry for notification tray if plugin/application is
48+
// not running in foreground.
49+
//
50+
// So first we check if the user has set the configuration to have multiple
51+
// notifications show in the tray (i.e. set <preference name="ParseMultiNotifications" value="true" />)
52+
ParsePushConfigReader config = new ParsePushConfigReader(context, null, new String[] {"ParseMultiNotifications"});
53+
String parseMulti = config.get("ParseMultiNotifications");
54+
if(parseMulti != null && !parseMulti.isEmpty() && parseMulti.equals("true")){
55+
// If the user wants multiple notifications in the tray, then we let ParsePushBroadcastReceiver
56+
// handle it from here
57+
super.onPushReceive(context, intent);
58+
} else {
59+
// use tag + notification id=0 to limit the number of notifications in the tray
60+
// (older messages with the same tag and notification id will be replaced)
61+
NotificationManager notifManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
62+
notifManager.notify(getNotificationTag(context, intent), 0, getNotification(context, intent));
63+
}
5264
//
5365
// A user with Android 5.0.1 reports that notif is not created in tray when
5466
// app is off (not background), trying method described here

0 commit comments

Comments
 (0)