iOS 模拟器 Mock Push Notification

108 阅读1分钟

先创建一个.apns文件(eg: test.apns)

{

    "Simulator Target Bundle": "# bundle id",

    "aps": {

        "alert": {

            "title": "# your title content",

            "subtitle": "# subtitle content",

            "body": "# body content"

        },

        "badge": 1,

        "sound": "default"

    },

    "data": {

        "xxxxx": "xxxxxx",
    },
    
    "mutable-content": 1, # Notification Extension 
    "content-available": 1, # Slient push
    "xxxxx": "xxxxxxxx"

}

然后进入对应目录下面执行下面代码:

xcrun simctl push 模拟器identifier test.apns

Note: 从这里可以获取Identifier

image.png