About Notification center messages (SF-0011)

Great changes to the NotificationCenter API. Now, instead of the abstract Notification, we can define a Sendable type and use it to post and observe messages. The message type must conform to MainActorMessage or AsyncMessage protocol. The first is for time-critical messages. The second is not tied to the main thread and supports AsyncSequence (see examples below).

Post continues below.

#swift

And the most important thing here is that we can use this API to subscribe to any notification available in Apple SDK. Finally, it will be possible to leave the notification name, userInfo dictionary and its keys in the past.

To find out more, follow the links below:
Documentation - https://developer.apple.com/documentation/foundation/notification-center-messages
WWDC link - https://developer.apple.com/videos/play/wwdc2025/245/?time=645
SF-0011 proposal - https://github.com/swiftlang/swift-foundation/blob/main/Proposals/0011-concurrency-safe-notifications.md

Notification center messages | Apple Developer Documentation

Use Foundation’s notification center with Swift concurrency.

Apple Developer Documentation