如何在 iOS 模拟器中模拟本地/推送通知? [英] How to simulate a local/push notification in iOS simulator?
问题描述
WatchKit 允许我们模拟通知使用 .apns
文件.
WatchKit allows us to simulate notifications with an .apns
file.
如何在 iOS 应用中做同样的事情?(最好在模拟器中.)
How can I do the same thing in an iOS app? (Preferably in the simulator.)
我问的原因是我想让调试器在应用程序最初通过通知启动时处于活动状态(即我想看看应用程序中发生了什么:didFinishLaunchingWithOptions: 方法).如果我开始一个新的调试会话,它将立即调用 application:didFinishLaunchingWithOptions:,然后当我点击通知时,我永远无法测试该代码路径.
The reason I ask is that I want to have the debugger active when the app is initially launched via a notification (i.e. I want to see what happens in the application:didFinishLaunchingWithOptions: method). If I start a new debugging session it will call application:didFinishLaunchingWithOptions: immediately, and then I can never test that code path when I tap on the notification.
推荐答案
没有任何方法可以在模拟器中模拟通知.您可以调试到真实设备并发送沙箱推送通知以在 Xcode 中调用该功能.
There isn't any way to simulate a notification in the simulator. You can debug to a real device and send a sandbox push notification to hit that function in Xcode.
这篇关于如何在 iOS 模拟器中模拟本地/推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!