I am receiving only one notification and if there comes another notification, it replaces the previous one and here is my code
private static void generateNo
i guess this will help someone..
in below code "not_nu" is an random int.. PendingIntent and Notification have the same ID .. so that on each notification click the intent will direct to different activity..
private void sendNotification(String message,String title,JSONObject extras) throws JSONException {
String id = extras.getString("actionParam");
Log.e("gcm","id = "+id);
Intent intent = new Intent(this, OrderDetailActivty.class);
intent.putExtra("id", id);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
final int not_nu=generateRandom();
PendingIntent pendingIntent = PendingIntent.getActivity(this, not_nu /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_cart_red)
.setContentTitle(title)
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(not_nu /* ID of notification */, notificationBuilder.build());
}
public int generateRandom(){
Random random = new Random();
return random.nextInt(9999 - 1000) + 1000;
}