因此,在向 Android 设备发送通知时,您可以提供标签属性:
So, when sending a notification to an Android device you can give a tag property:
"notification": {
"title": title,
"body": message,
"sound": sound,
"tag": "STRING_TO_GROUP_NOTIFICATIONS_BY"
}
这会将具有相同标签的通知组合在一起,这样它们就不会在用户通知很多时弄乱用户通知,并且只显示最新的通知.
This groups notifications with the same tag together so that they don't make a mess of the users notifications when there are a lot and only shows the newest one.
这在聊天应用程序中非常有用,它具有多个接收大量消息的频道,因此您可以按频道分组并最大限度地减少用户通知中的噪音.
This is really useful in say, a chat app, with multiple channels that receive lots of messages so you can group by channel and minimize the amount of noise in the user's notifications.
总是……
iOS 有什么方法可以做到这一点吗?
Is there any way to do this with iOS?
更新:apns-collapse-id
已经可用于 FCM v1:
Update: apns-collapse-id
is already available for FCM v1:
FCM 为发送到 Android 设备的消息提供一组特定的传递选项,并允许在 iOS 和 Web 上提供类似选项.例如,Android 上通过 FCM 的 collapse_key 支持可折叠"消息行为,iOS 上通过 apns-collapse-id
支持,JavaScript/Web 上通过 Topic 支持.详见本节说明及相关参考文档
FCM provides a specific set of delivery options for messages sent to Android devices, and allows for similar options on iOS and web. For example, "collapsible" message behavior is supported on Android via FCM's collapse_key, on iOS via
apns-collapse-id
, and on JavaScript/Web via Topic. For details, see descriptions in this section and related reference documentation
<小时>
标签
参数目前仅支持 Android(您可能已经知道这就是您寻找 iOS 的原因),并且目前在 iOS 中没有对应的参数.
The tag
parameter is currently only supported for Android (which you probably already know which is why you're looking for iOS) and there is currently no counterpart for it in iOS.
来自我的在这里回答:
为了在 iOS 中捆绑通知,您必须指定 thread-id
:
In order to bundle notifications in iOS, you'll have to specify a thread-id
:
为该键提供一个字符串值,该字符串值表示用于分组通知的特定于应用程序的标识符.系统在通知中心和其他系统界面中将具有相同线程标识符的通知分组在一起.对于本地通知,此键对应于 threadIdentifier 属性一个 href="https://developer.apple.com/reference/usernotifications/unnotificationcontent" rel="nofollow noreferrer">UNNotificationContent 对象.
Provide this key with a string value that represents the app-specific identifier for grouping notifications. The system groups notifications with the same thread identifier together in Notification Center and other system interfaces. For local notifications, this key corresponds to the threadIdentifier property of the UNNotificationContent object.
但是,FCM 中目前没有thread-id
的参数counterpart.您可以尝试做的是利用 data
消息负载并将 thread-id
指定为自定义键值对.
However, there is currently no parameter counterpart for thread-id
in FCM. What you could try and do is make use of a data
message payload and specify the thread-id
as a custom key-value pair.
一些可能有用的帖子:
这篇关于FCM/GCM 通过“标签"对通知进行分组.在 iOS 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!