推送通知参数本地化

Push notification arguments localization

我知道可以使用 title-loc-keytitle-loc-argsloc-keyloc-args 来本地化推送通知的消息和标题。因此,系统在应用程序包中搜索 localized-title-formatted-string(title-loc-key) 并将 format-specifiers 替换为 title-loc-args

我的问题是是否可以本地化推送通知的参数?以便系统将 formatted-string 的 format-specifiers 替换为本地化的 title-loc-args(参数替换为在应用程序包中找到的本地化值)。

例如:

通知:

`title-loc-key`= "localization_key_shipping"
`title-loc-args`= ["localization_key_headset"]

本地化英语:

"localization_key_shipping" = "Your %@ is ready for shipping"
"localization_key_headset" = "headset";

我可以让这个作品看看吗"Your headset is ready for shipping"

感谢您的所有建议和意见。

不,您的服务器端代码应该为参数提供本地化文本。 See Apple docs.

查看通知服务扩展。这就是您可以在向用户显示之前修改推送通知内容的方法。

https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension

A UNNotificationServiceExtension object provides the entry point for a notification service app extension. This object lets you customize the content of a remote notification before the system delivers it to the user. A notification service app extension doesn’t present any UI of its own. Instead, it’s launched on demand when the system delivers a notification of the appropriate type to the user’s device. You use this extension to modify the notification’s content or download content related to the extension. For example, you could use the extension to decrypt an encrypted data block or to download images associated with the notification.