无法在ios设备上模拟推送通知

dso*_*ave 2 xcode apn push-notification apple-push-notifications swift

我正在阅读一篇raywenderlich.com关于推送通知入门的文章,因为我想在我的应用程序上尝试一下,并且能够轻松地跟进,直到在终端中运行命令并实际模拟通知的部分。

当我运行该命令时xcrun simctl push 'device identifier here' site.bundleidentifier.example eventnotification.apn,我收到一条错误消息Invalid device: 'device identifier here'。我似乎无法弄清楚这个问题,我直接从 Xcode 获得了标识符。我转到“窗口”->“设备和模拟器”->“设备”并获取手机的标识符。我似乎不知道如何解决该错误,如果有人知道我如何解决这个问题,那就太好了,谢谢。

文章链接:推送通知文章 Ray Wenderlich

jn_*_*pdx 8

听起来您可能正在尝试使用实际手机执行此操作。该命令是指推送到模拟器(simctl是控制模拟器的命令行应用程序)。

您可以通过执行以下终端命令列出可用的设备:

xcrun simctl list 'devices' 'booted'
Run Code Online (Sandbox Code Playgroud)

一个很好的技巧就是使用booted开放的模拟器。因此,示例命令可能是:

xcrun simctl push booted com.myprogram.app payload.json
Run Code Online (Sandbox Code Playgroud)

或者,如果您想使用完整的设备 ID:

xcrun simctl push 'xxxxxxx-7C2B-4B0D-A0E2-xxxxxxxxx' com.myprogram.app payload.json
Run Code Online (Sandbox Code Playgroud)

您可以将单引号中的信息替换为您的设备 ID。