gpt4 book ai didi

ios - swift 3 - 推送通知的本地化不起作用

转载 作者:行者123 更新时间:2023-11-28 15:27:26 25 4
gpt4 key购买 nike

我正在尝试使用有效负载本地化推送通知(swift 3、ios 10):

{ 
"aps":{
"alert":{
"title_loc_key":"NOTIFICATION_NEW_FRIEND_REQUEST_TITLE",
"title-loc-args":[],
"loc_key":"NOTIFICATION_NEW_FRIEND_REQUEST_BODY",
"loc-args":[]
},
"mutable_content":1,
"category":"new_friend_request",
"badge":0,
"sound":"default"
}
}

在 Localizable.strings 上我有:

"NOTIFICATION_NEW_FRIEND_REQUEST_TITLE" = "some text";
"NOTIFICATION_NEW_FRIEND_REQUEST_BODY" = "some text"

我的系统语言是英文问题是通知来了(我的 Iphone 正在振动)但没有显示任何内容。有什么问题以及如何解决?

最佳答案

title_loc_keytitle-loc-keyloc_keyloc-key

doc使用 - 定义关键字分隔符并且您正在混合(使用 - 用于 ...arg_ 用于 ...键)

Storing Localized Content in Your App Bundle

If you use a consistent set of messages for your notifications, you can store localized versions of the message text in your app bundle and use the loc-key and loc-args keys in your payload to specify which message to display. The loc-key and loc-args keys define the message content of the notification. When present, the local system searches the app’s Localizable.strings files for a key string matching the value in loc-key. It then uses the corresponding value from the strings file as the basis for the message text, replacing any placeholder values with the strings specified by the loc-args key. (You can also specify a title string for the notification using the title-loc-key and title-loc-args keys.)

关于ios - swift 3 - 推送通知的本地化不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45053216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com