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

时间:2021-09-16 20:39:02

WatchKit allows us to simulate notifications with an .apns file.

WatchKit允许我们使用.apns文件模拟通知。

How can I do the same thing in an iOS app? (Preferably in the simulator.)

我怎么能在iOS应用程序中做同样的事情? (最好在模拟器中。)

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.

我问的原因是我希望在最初通过通知启动应用程序时调试器处于活动状态(即我想看看应用程序中发生了什么:didFinishLaunchingWithOptions:方法)。如果我启动一个新的调试会话,它将立即调用application:didFinishLaunchingWithOptions:然后,当我点击通知时,我永远无法测试该代码路径。

1 个解决方案

#1


2  

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中命中该功能。

#1


2  

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中命中该功能。