App 图标的角标未读消息数

krismile 2天前 17

hello,请教一下,离线推送时 App 图标的角标未读消息数,如何确保厂商通道的推送携带准确的参数呢,是im侧控制的吗

最新回复 (1)
  • x86 2天前
    引用 2

    这个不是 im 侧控制的,是系统控制的。

    发送通知时,可以设置一个 Number 参数,然后系统会在当前角标数字的基础上加上这个 number 值;如果没设置的话,会加 1

           NotificationCompat.Builder builder = new NotificationCompat.Builder(context, wfcNotificationChannelId)
                .setSmallIcon(R.mipmap.ic_launcher_notification)
                .setAutoCancel(true)
                .setNumber(number) // 角标会加上这个值
                .setCategory(CATEGORY_MESSAGE)
                .setSound(notificationRingUri)
                .setPriority(NotificationCompat.PRIORITY_HIGH)
                .setDefaults(DEFAULT_ALL);
            builder.setContentIntent(pendingIntent);
            builder.setContentTitle(title);
            builder.setContentText(content);
返回