iOS 模拟器推送通知(xcode 11.4)
2020-05-18 本文已影响0人
VervertomJC
转:iOS开发之模拟器测试远程推送
xcrun simctl push --help
Send a simulated push notification
Usage: simctl push <device> [<bundle identifier>] (<json file> | -)
bundle identifier
The bundle identifier of the target application
If the payload file contains a 'Simulator Target Bundle' top-level
key this parameter may be omitted.
If both are provided this argument will override the value from the payload.
json file
Path to a JSON payload or '-' to read from stdin. The payload must:
- Contain an object at the top level.
- Contain an 'aps' key with valid Apple Push Notification values.
- Be 4096 bytes or less.
Only application remote push notifications are supported. VoIP,
Complication, File Provider, and other types are not supported.
参数解释
device :只需将其设置为booted即可使用已经启动的模拟器。 还可以使用xcrun simctl list devices | grep Booted查看已经启动的模拟器。
xcrun simctl list devices | grep Booted iPhone 11 Pro Max (97AE0B1F-4C63-4B02-906B-8B2CF9E3F4B0) (Booted)
json 通知格式(payload.json)
{
"aps":{
"alert":{
"title":"测试",
"subtitle":"远程推送",
"body":"这是一条从远处而来的通知"
},
"sound":"default",
"badge":1
}
}
推送通知xcrun simctl push booted bundleid /path/to/playload.json