android 动态权限推送图标问题,firebase - 如何在Android和iOS中收到的推送通知上设置徽章? - 堆栈内存溢出...

我试图在移动设备上收到推送通知时使用react native firebase在应用程序图标上设置徽章计数。 但是无法动态设置应用程序图标上的计数值。

这是我的代码-

const channel = new firebase.notifications.Android.Channel(

'demo',

'DEMO',

firebase.notifications.Android.Importance.Max

).setDescription('DEMO APP');

firebase.notifications().android.createChannel(channel);

this.notificationListener = firebase.notifications().onNotification((notification) => {

const { title, body, id } = notification.data;

this.title = title;

this.body = body;

this.id = id;

const localNotification = new firebase.notifications.Notification({

sound: 'default',

show_in_foreground: true,

})

.setNotificationId(notification.notificationId)

.setTitle(notification.title)

.setBody(notification.body)

.setData(notification.data)

.setBadge(notification.id)

.android.setAutoCancel(true)

.android.setChannelId('demo') // e.g. the id you chose above

.android.setSmallIcon('ic_launcher') // create this icon in Android Studio

.android.setColor('#000000') // you can set a color here

.android.setPriority(firebase.notifications.Android.Priority.High);

firebase.notifications()

.displayNotification(localNotification)

.catch(err => console.error(err));

});

}

请帮助任何人对此有解决方案。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值