When the general server does APNS push, it is commonly used

{  
 "aps" : {  
 	"alert" : "I'm being pushed."."badge" : 1,
 	"sound" : "default"}}Copy the code

This format, yes, I also wrote in this way at the beginning, but later, the design to do multi-language push, so it can not do so

{  
 "aps" : {  
 "alert" : {
       "body" : "I'm a push message."."action-loc-key" : "Play_MSG"."loc-key":"Borrow_MSG"."loc-args": ["XYZ"]},"badge" : 1,
 "sound" : "default"}}Copy the code

Explanation:

(1) Loc-key: a multi-language field defined in the Localizable. Strings file of the App end; (2) Loc-ARgs: parameters that need to be carried in the multi-language fields of the App end; The “loc-args” field is also not required and can be omitted if no parameter is required in the multi-language field of “loc-key”. For example, the multi-language field defined by “Borrow_MSG” in “Loc-key” is “%@ wants to borrow %@’s money”. Then the value of “loc-args” should be [“LiLei”, “HanMeimei”]. Finally, the push message displayed on the App end is “LiLei wants to Borrow HanMeimei’s money”. (3) action-loc-key: The Localizable. String file of the App server defines a multi-language field, which is not required to replace the “action-loc-key” field in the View button of the lock screen page. The “view” in “Slide to View” is the defined multilingual field “Play_MSG”.

(4) Body: field displayed in push; (After testing, if loc-key is defined, If the lock-key is not found in the Localizable. Strings file, the body will be displayed directly. The name of an image file to be applied in the bundle. Normally we do not specify this property; Specific can consult https://blog.csdn.net/olivelao/article/details/60958526 this blog to write well