Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Use unique pending intent request code to enable multiple simultaneou…
Browse files Browse the repository at this point in the history
…s notifications with action buttons (#1216)
  • Loading branch information
mikepsinn authored and macdonst committed Sep 13, 2016
1 parent 0a93fab commit 1fe6406
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/android/com/adobe/phonegap/push/GCMIntentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ private void createActions(Bundle extras, NotificationCompat.Builder mBuilder, R
JSONArray actionsArray = new JSONArray(actions);
ArrayList<NotificationCompat.Action> wActions = new ArrayList<NotificationCompat.Action>();
for (int i=0; i < actionsArray.length(); i++) {
int uniquePendingIntentRequestCode = i + notId;
Log.d(LOG_TAG, "adding action");
JSONObject action = actionsArray.getJSONObject(i);
Log.d(LOG_TAG, "adding callback = " + action.getString(CALLBACK));
Expand All @@ -399,20 +400,20 @@ private void createActions(Bundle extras, NotificationCompat.Builder mBuilder, R
updateIntent(intent, action.getString(CALLBACK), extras, foreground, notId);

if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.M) {
Log.d(LOG_TAG, "push activity");
pIntent = PendingIntent.getActivity(this, i, intent, PendingIntent.FLAG_ONE_SHOT);
Log.d(LOG_TAG, "push activity for notId " + notId);
pIntent = PendingIntent.getActivity(this, uniquePendingIntentRequestCode, intent, PendingIntent.FLAG_ONE_SHOT);
} else {
Log.d(LOG_TAG, "push receiver");
pIntent = PendingIntent.getBroadcast(this, i, intent, PendingIntent.FLAG_ONE_SHOT);
Log.d(LOG_TAG, "push receiver for notId " + notId);
pIntent = PendingIntent.getBroadcast(this, uniquePendingIntentRequestCode, intent, PendingIntent.FLAG_ONE_SHOT);
}
} else if (foreground) {
intent = new Intent(this, PushHandlerActivity.class);
updateIntent(intent, action.getString(CALLBACK), extras, foreground, notId);
pIntent = PendingIntent.getActivity(this, i, intent, PendingIntent.FLAG_UPDATE_CURRENT);
pIntent = PendingIntent.getActivity(this, uniquePendingIntentRequestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
} else {
intent = new Intent(this, BackgroundActionButtonHandler.class);
updateIntent(intent, action.getString(CALLBACK), extras, foreground, notId);
pIntent = PendingIntent.getBroadcast(this, i, intent, PendingIntent.FLAG_UPDATE_CURRENT);
pIntent = PendingIntent.getBroadcast(this, uniquePendingIntentRequestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}

NotificationCompat.Action.Builder actionBuilder =
Expand Down

0 comments on commit 1fe6406

Please sign in to comment.