【问题标题】:NotificationCompat.Action shows only one action button FCM Push NotificationNotificationCompat.Action 仅显示一个操作按钮 FCM 推送通知
【发布时间】:2020-06-30 06:21:48
【问题描述】:

我正在实施 Firebase 推送通知。它有 2 个动作按钮 Accept 和 Decline,它是一个来自数据负载的数组。

当按下触发时,它只显示拒绝按钮。两个按钮都没有显示。

下面是我的代码

  NotificationCompat.Builder(this, channelId)
                .setSmallIcon(R.drawable.push_small_icon)
                .setStyle(NotificationCompat.BigPictureStyle().bigPicture(bitmap))
                .setContentTitle(remoteMessage.data[Const.TITLE])
                .setContentText(remoteMessage.data[Const.MESSAGE])
                .setPriority(Notification.PRIORITY_MAX)
                .addAction(action) // Action buttons
                .setAutoCancel(true)`enter code here`
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent)

请帮我解决这个问题。

谢谢

【问题讨论】:

  • 你找到解决这个问题的方法了吗?我可以添加多个操作按钮,但如果用户单击任何按钮,所有其他类似通知的按钮都会被禁用。

标签: android push-notification firebase-cloud-messaging action-button


【解决方案1】:

试试这个,显示更多Notification with multiple buttons

notificationBuilder.addAction(R.drawable.delete, "Delete", PendingIntent.getActivity(this, CANCELNOTIFICATIONID, deleteIntent, 0));
notificationBuilder.addAction(R.drawable.archive, "Archive", PendingIntent.getActivity(this, CANCELNOTIFICATIONID, archiveIntent, 0));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-16
    • 2023-03-10
    • 2017-03-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多