Skip to content

Commit

Permalink
Multiple Push Notification Issues
Browse files Browse the repository at this point in the history
Cordova Phone Push Plugin Multiple Push Notifications Creating but not opening when tapped on the created notification

Always open last send push notification By Javascript Code
  • Loading branch information
manjeshpv committed Sep 29, 2014
1 parent f1fa935 commit cdd1f56
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/android/com/plugin/gcm/GCMIntentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,27 @@ protected void onMessage(Context context, Intent intent) {

public void createNotification(Context context, Bundle extras)
{
int notId = 0;

try {
notId = Integer.parseInt(extras.getString("notId"));
}
catch(NumberFormatException e) {
Log.e(TAG, "Number format exception - Error parsing Notification ID: " + e.getMessage());
}
catch(Exception e) {
Log.e(TAG, "Number format exception - Error parsing Notification ID" + e.getMessage());
}


NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String appName = getAppName(this);

Intent notificationIntent = new Intent(this, PushHandlerActivity.class);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
notificationIntent.putExtra("pushBundle", extras);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent contentIntent = PendingIntent.getActivity(this, notId, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

int defaults = Notification.DEFAULT_ALL;

Expand Down Expand Up @@ -120,18 +133,7 @@ public void createNotification(Context context, Bundle extras)
mBuilder.setNumber(Integer.parseInt(msgcnt));
}

int notId = 0;

try {
notId = Integer.parseInt(extras.getString("notId"));
}
catch(NumberFormatException e) {
Log.e(TAG, "Number format exception - Error parsing Notification ID: " + e.getMessage());
}
catch(Exception e) {
Log.e(TAG, "Number format exception - Error parsing Notification ID" + e.getMessage());
}


mNotificationManager.notify((String) appName, notId, mBuilder.build());
}

Expand Down

1 comment on commit cdd1f56

@paragghadge
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not working. Did same changes as shown above.

Please sign in to comment.