简体   繁体   English

如何在 iOS 模拟器中模拟本地/推送通知?

[英]How to simulate a local/push notification in iOS simulator?

WatchKit allows us to simulate notifications with an .apns file. WatchKit 允许我们使用.apns文件模拟通知

How can I do the same thing in an iOS app?如何在 iOS 应用中做同样的事情? (Preferably in the simulator.) (最好在模拟器中。)

The reason I ask is that I want to have the debugger active when the app is initially launched via a notification (ie I want to see what happens in the application:didFinishLaunchingWithOptions: method).我问的原因是我想让调试器在应用程序最初通过通知启动时处于活动状态(即我想看看在 application:didFinishLaunchingWithOptions: 方法中发生了什么)。 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.如果我开始一个新的调试会话,它将立即调用 application:didFinishLaunchingWithOptions: ,然后当我点击通知时我永远无法测试该代码路径。

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.您可以调试到真实设备并发送沙箱推送通知以在 Xcode 中调用该功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM