Hi, everybody!
The `thread-id` APNs payload field was introduced earlier this year. According to the APNs docs, users should:
> 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.
In testing, though, I haven't been able to spot any differences in behavior between notifications with and without a thread ID. I've tried:
- Sending only notifications with the same thread ID
- Sending notifications with different thread IDs
- Sending a combination of notifications with and without thread IDs
- Sending notifications to multiple apps with various combinations of thread IDs
In all cases, notifications seem to appear on the home screen in the order in which they were received and in Notification Center in the order they were received, but grouped by application. What actual behavioral changes should I be looking for with a thread ID? Thanks!
As Adam Jones of the apns2 project points out, the behavior we're looking for here is actually pretty subtle. It appears that iOS itself won't do much with the thread ID, but instead gives the receiving application an opportunity to take action. A better explanation from the didReceiveNotification: docs:
> The system calls this method to deliver notifications to your Notification Content app extension. Use this method to configure the contents of your view controller or to incorporate content from a new notification. This method may be called multiple times while your view controller is visible. Specifically, it is called again when a new notification arrives whose
threadIdentifier
value matches the thread identifier of the notification already being displayed. The method is called on the main thread of your extension.