FCM/GCM grouping notifications by “tag” on iOS

2019-04-12 16:31发布

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.

Anways...

Is there any way to do this with iOS?

1条回答
来,给爷笑一个
2楼-- · 2019-04-12 17:17

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.

From my answer here:

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

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.

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.

Some possibly helpful posts:

查看更多
登录 后发表回答