|
10 | 10 | import android.app.Notification; |
11 | 11 | import android.app.NotificationManager; |
12 | 12 |
|
| 13 | +import github.taivo.parsepushplugin.ParsePushConfigReader; |
| 14 | +import github.taivo.parsepushplugin.ParsePushConfigException; |
| 15 | + |
13 | 16 | import android.support.v4.app.NotificationCompat; |
14 | 17 |
|
15 | 18 | import android.net.Uri; |
@@ -40,15 +43,24 @@ protected void onPushReceive(Context context, Intent intent) { |
40 | 43 | // relay the push notification data to the javascript |
41 | 44 | ParsePushPlugin.jsCallback( getPushData(intent) ); |
42 | 45 | } 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 | + } |
52 | 64 | // |
53 | 65 | // A user with Android 5.0.1 reports that notif is not created in tray when |
54 | 66 | // app is off (not background), trying method described here |
|
0 commit comments