gpt4 book ai didi

android - Firebase 多推送通知不起作用

转载 作者:行者123 更新时间:2023-11-30 00:18:56 28 4
gpt4 key购买 nike

如果我使用 firebase 向我的应用程序发送 3 个推送数据通知,我首先点击的那个只是打开并且所有数据都显示 whlie rest 2 当点击时永远不会打开我的应用程序。下面是我给出的接收数据消息的代码,请看一下。

 private void sendNotification(String message, Bitmap image, String objIdOS, String objIdVenInv, String typeVenInv, String cls, String checkTest, String colName, String title, String position) {
Intent intent = new Intent(this, UserLogin.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("objIdOS",objIdOS);
intent.putExtra("objIdVenInv",objIdVenInv);
intent.putExtra("typeVenInv",typeVenInv);
intent.putExtra("cls",cls);
intent.putExtra("checkTest",checkTest);
intent.putExtra("colName",colName);
intent.putExtra("pos",position);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setContentTitle(title)
.setContentText(message)
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setAutoCancel(true)
.setSound( Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.clean))
.setOnlyAlertOnce(true)
.setPriority(Notification.PRIORITY_MAX)
.setContentIntent(pendingIntent)
.setColor(Color.parseColor("#1ABC9C"))
.setSmallIcon(R.drawable.small_icon);
if (image!=null){
notificationBuilder.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(image).setSummaryText(message)); /*Notification with Image*/
}

/*if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
notificationBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.splash_icon3));
} else {
notificationBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.splash_icon3));
}*/

NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

notificationManager.notify(notificationId, notificationBuilder.build());
}

最佳答案

添加这个

    (int)SystemClock.currentThreadTimeMillis()

PendingIntent.getActivity(this, (int)SystemClock.currentThreadTimeMillis() /* Request code */, intent,
PendingIntent.FLAG_UPDATE_CURRENT);


notificationManager.notify((int)SystemClock.currentThreadTimeMillis(), notificationBuilder.build());

关于android - Firebase 多推送通知不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46686271/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com