Multiple notification from GCM not directing to correct activity

前端 未结 1 1013
面向向阳花
面向向阳花 2021-01-07 15:20

I am using GCM for push notifications. My constraint is that from the received bundle from GCM server I have to redirect user to specific location in my application. Every t

1条回答
  •  孤城傲影
    2021-01-07 16:10

    You can try the below code.. (try using FLAG_UPDATE_CURRENT)

    private void sendNotification(String msg) {
            mNotificationManager = (NotificationManager)
                    this.getSystemService(Context.NOTIFICATION_SERVICE);
    
            Intent myintent = new Intent(this, ReceiveActivity.class);
            myintent.putExtra("message", msg);
            PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                    myintent, PendingIntent.FLAG_UPDATE_CURRENT);
    
            NotificationCompat.Builder mBuilder =
                    new NotificationCompat.Builder(this)
           // .setSmallIcon(R.drawable.ic_stat_gcm)
            .setContentTitle("GCM Notification")
            .setStyle(new NotificationCompat.BigTextStyle()
            .bigText(msg))
            .setContentText(msg);
    
            mBuilder.setContentIntent(contentIntent);
            mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    
    
        }
    

    0 讨论(0)
提交回复
热议问题