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

swift 3 - localization for push notification not work

我正在尝试使用有效载荷本地化推送通知(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_key 对比 title-loc-keyloc_key 对比 loc-key

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

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.)