Why NSString.localizedUserNotificationString

Apple's docs show using NSString.localizedUserNotificationString for local push notifications in Swift. Why not just use the normal NSLocalizedString() methods? Is there something special about the former method?

Replies

The method is so that the localization can be correct for a notification if the user's locale changes and there are notifications already scheduled or displayed. If you schedule a notification in one locale and resolve the copy at creation time, you won't be able to update the notification to another language afterwards. This special method perceives the localization key and allows the translation to happen at runtime or so that it can be dynamically updated if the locale changes.