如何在不使用ios设备的情况下使用Xcode 11.4及以上版本在IOS模拟器中测试推送通知。
Xcode 11.4及以上版本支持使用模拟器测试推送通知。
要测试
Controlroom是一个神奇的应用程序,我最近遇到了,它允许控制模拟器。它提供了一个很好的UI来定制通知。特别感谢Paul Hudson在git.Git URL中分享源代码。https:/github.comtwostrawsControlRoom。
在终端上运行以下命令
xcrun simctl push <simulator identifier> <bundle identifier of the app> <pushcontentfile>.apns"
Xcode Menu => Window => Devices and Simulators
{
"aps": {
"alert": "Push Notifications Test",
"sound": "default",
"badge": 1
}
}
.apns文件应该包含应用程序的捆绑标识符,作为有效载荷的一部分。
{
"Simulator Target Bundle": "<bundle identifier of the app>",
"aps": {
"alert": "Push Notifications Test",
"sound": "default",
"badge": 1
}
}