通过推送通知启动时调试应用程序 [英] Debugging App When Launched by Push Notification

查看:21
本文介绍了通过推送通知启动时调试应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个接收推送通知的应用程序.我让这一切都通过 PHP 页面 100% 工作.我的应用程序可以接收多种不同类型的推送通知.PHP 处理这个并将不同的信息包发送到我的应用程序,这些信息包都收到了.

I am currently developing an app that receives Push Notifications. I have this all working 100% through a PHP page. There are several different types of push notifications my app can receive. The PHP handles this and sends different packets of information to my app which are all received just fine.

但是,当用户查看"通知并且我的应用程序启动时,我显然想要采取与用户手动启动应用程序不同的操作 - 最重要的是,根据推送的不同采取不同的操作通知类型.我已经让这个工作正常......在结构上.

However, when the users "views" the notification and my app launches, I obviously want to take a different action than I would if the user just launched the app manually - and on top of that, different actions depending on the push notification type. I have got this working fine... structurally.

我的一种推送类型应该打开一个 UIView,该 UIView 与多个不同的服务器建立多个连接并来回协商数据.例如,当从主菜单触发时,此 UIView 工作正常 - 但是,当我的推送通知触发此 UIView 出现时,套接字连接未按预期运行.

One of my push types is supposed to open a UIView that makes several connections to several different servers and negotiates data back and forth. This UIView works fine when, for example, triggered from the main menu - however when my push notification is triggering this UIView to appear, the socket connections are not acting as expected.

现在我的问题不是关于套接字,而是更多 - 你如何调试这样的问题?据我所知(我相对较新)当应用程序从推送通知启动时,无法将该执行链接到调试器/控制台/等......我在尝试调试代码时遇到了非常困难的时间UIAlertViews,因为各个服务器之间有很多来回的通信线路.

Now my question is not about the sockets, but more so - How do you debug such a problem?? From what I can tell (I am relatively new) when the app launched from a push notification there is no way to link that execution to the debugger / console / etc... I am having a very difficult time trying to debug the code using UIAlertViews, as there are many lines of communication back and forth between the various servers.

您对我的任何建议将不胜感激.

Any advice you have for me would be greatly appreciated.

推荐答案

在 Xcode

4.0(对于 Xcode >= 4,请参阅下面 delirus 的回答),您现在可以配置 Xcode 以在启动应用程序后将调试器附加到应用程序,而不是通过调试器启动应用程序.这让您可以调试因应用启动状态而异的内容,例如网址架构、粘贴板和推送通知.

In Xcode < 4.0 (for Xcode >= 4, see answer by delirus below), you can now configure Xcode to attach the debugger to the app after you launch it, instead of launching the app through the debugger. This lets you debug things that vary based on the launch state of your application, such as URL schemes, pasteboards, and push notifications.

  1. 在 Xcode 中查看 Source 栏中,Targets 下方将是 Executables.
  2. 在可执行文件中为您的应用打开检查器.
  3. 单击检查器中的调试"选项卡.
  4. 取消选中启动调试器后启动可执行文件"
  5. 选中等待下一次启动/推送通知"

现在,当您从 Xcode 中单击调试而不是启动应用程序时,将显示一个窗口,告诉它正在等待应用程序启动.然后您在手机上正常启动应用程序,Xcode 会附加到它

Now when you click debug from Xcode instead of launching the app a window will display telling it is waiting for the app to launch. You then launch the app normally on the phone and Xcode attaches to it

这篇关于通过推送通知启动时调试应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆