gpt4 book ai didi

react-native - 按 ID 分组通知并像 Whatsapp 一样显示

转载 作者:行者123 更新时间:2023-12-04 12:56:43 24 4
gpt4 key购买 nike

我一直在尝试按 id 对通知进行分组,例如将它们显示为 WhatsApp,而每行没有一个通知。

添加 setGroup在任一 onNotificationonNotificationDisplayed似乎没有效果见下面的例子:

1

componentDidMount() {
this.notificationListener = firebase.notifications().onNotification(async (notification) => {
// Process your notification as required
notification.android.setAutoCancel(true)

notification.android.setGroup(notification.data.channelId)
notification.android.setGroupSummary(true)
}
}

2
componentDidMount() {
this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
notification.android.setGroup(notification.data.channelId)
notification.android.setGroupSummary(true)
});
}

知道如何按 id 对它们进行分组吗?

最佳答案

这个怎么样:-

componentDidMount() {
var zero = firebase.notifications().onNotification((notification) => {
this.setState({
channelId=notification.data.channelId,
Title=notification.data.Title,
Body=notification.data.Body
//basically get all the data from the notification the you receieve from notification into states.
});
});
if(this.state.channelId === "WhatsApp"){
this.notificationDisplayedListener =
notification.android.setAutoCancel(true)
notification.android.setTitle(this.state.Title)
notification.android.setBody(this.state.Body)
notification.android.setGroup(this.state.channelId)
notification.android.setGroupSummary(true)
}
}

关于react-native - 按 ID 分组通知并像 Whatsapp 一样显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56518235/

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