Firebase推送通知云消息传递如何将其他数据作为通知访问

时间:2019-03-25 11:03:29

标签: java android firebase push-notification

enter image description here

我只想访问点击操作中写在附加选项内的那些自定义数据

    private void showNotification(String title, String message,String category,String index) {
     Intent intent=new Intent(getApplicationContext(),MyActivity.class);break;    
     PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(),0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
     NotificationCompat.Builder b = new NotificationCompat.Builder(getApplicationContext());
     b.setAutoCancel(true)
        .setDefaults(Notification.DEFAULT_ALL)
        .setWhen(System.currentTimeMillis())
        .setSmallIcon(R.mipmap.ic_launcher)
        .setContentTitle(title)
        .setContentText(message)
        .setContentIntent(contentIntent);
     NotificationManager notificationManager = (NotificationManager)getBaseContext().getSystemService(Context.NOTIFICATION_SERVICE);
     notificationManager.notify(1,b.build());
}

1 个答案:

答案 0 :(得分:0)

如果其他人遇到相同的问题,我可以自己解决此问题,您可以使用此功能

.getData();