通过" tag&"的FCM/GCM分组通知在iOS上 [英] FCM/GCM grouping notifications by "tag" on iOS

查看:169
本文介绍了通过" tag&"的FCM/GCM分组通知在iOS上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,在向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?

推荐答案

更新:

Update: apns-collapse-id is already available for FCM v1:

FCM为发送到Android设备的邮件提供了一组特定的传递选项,并允许在iOS和Web上使用类似的选项.例如,在Android上通过FCM的crash_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


tag 参数目前仅受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中捆绑 通知,您必须指定

In order to bundle notifications in iOS, you'll have to specify a thread-id:

为此键提供一个字符串值,该字符串值表示用于分组通知的特定于应用程序的标识符.系统在Notification Center和其他系统界面中将具有相同线程标识符的通知分组在一起.对于本地通知,此键对应于<< threadIdentifier 属性的 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.

一些可能有用的帖子:

  • https://stackoverflow.com/a/37621274/4625829
  • iOS "thread-id" doesn't group push notifications
  • iOS 10 How to set UNotificationContent threadIdentifier for remote notification

这篇关于通过&quot; tag&amp;&quot;的FCM/GCM分组通知在iOS上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆