通过推送通知启动应用程序时进行调试

发布于 2024-07-29 20:33:27 字数 531 浏览 2 评论 0原文

我目前正在开发一个接收推送通知的应用程序。 我通过 PHP 页面使这一切 100% 正常工作。 我的应用程序可以接收多种不同类型的推送通知。 PHP 处理这个问题并向我的应用程序发送不同的信息包,这些信息包都被很好地接收。

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

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

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

如果您对我有任何建议,我将不胜感激。

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.

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

荒人说梦 2024-08-05 20:33:27

在Xcode中< 4.0(对于 Xcode >= 4,请参阅下面 delirus 的回答),您现在可以配置 Xcode 在启动应用程序后将调试器附加到应用程序,而不是通过调试器启动应用程序。 这使您可以调试根据应用程序的启动状态而变化的内容,例如 URL 方案、粘贴板和推送通知。

  1. 在 Xcode 中,查看“源”栏,在“目标”下方将有“可执行文件”。
  2. 在可执行文件中调出应用程序的检查器。
  3. 单击检查器中的“调试”选项卡。
  4. 取消选中“启动调试器后启动可执行文件”
  5. 选中“等待下一次启动/推送通知”

现在,当您从 Xcode 单击“调试”而不是启动应用程序时,将显示一个窗口,告诉它正在等待应用程序启动。 然后,您可以在手机上正常启动该应用程序,并且 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. In Xcode look in the Source bar, and below Targets there will be Executables.
  2. Bring up the inspector for your app in executables.
  3. Click on the Debugging tab tab in the inspector.
  4. Uncheck "Start executable after starting debugger"
  5. Check the "Wait for next launch/push notification"

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

廻憶裏菂餘溫 2024-08-05 20:33:27

对于 Xcode 4,您必须:

  1. 通过以下方式编辑您的活动方案
    “方案”下拉菜单。 (+<)
  2. 然后选择您的产品 - '运行
    MyApp.app' 在左侧。
  3. 选择右侧的“信息”选项卡。
  4. 最后选择“等待
    MyApp.app to launch”选项。

更多信息此处 在“方案编辑器中自定义可执行文件”部分

编辑:
如果您错过 GDB 中的日志,请参阅 Louis Gerbarg 的 评论 他的回答。

For Xcode 4 you have to:

  1. Edit your active scheme via
    "Schemes" dropdown. (+<)
  2. Than choose your product - 'Run
    MyApp.app' on the left.
  3. Select 'Info' tab on the right.
  4. And finally choose "Wait for
    MyApp.app to launch" option.

More here in "Customize Executables in the Scheme Editor" section.

EDIT:
In case you miss logs in GDB, see Louis Gerbarg's comment to his answer.

时光清浅 2024-08-05 20:33:27

适用于 Xcode 10、9、8、7 和 6:

  1. 在工具栏上选择方案(就在您正在调试的设备的左侧)
  2. 选择编辑方案
  3. 选择运行在左侧面板中,
  4. 对于启动选项,选择等待可执行文件启动
  5. 关闭方案编辑器并运行您的 Xcode 项目

现在您可以调试从通知、自定义 URL 或触摸应用程序图标启动时。

For Xcode 10, 9, 8, 7 & 6:

  1. Select the Scheme on the toolbar (just left of the device you're debugging with)
  2. Choose Edit Scheme
  3. Select Run in the left panel
  4. For the Launch option, select Wait for executable to be launched
  5. Close the Scheme Editor and Run your Xcode project

Now you can debug when launching from a notification, custom url or by touching the app icon.

请持续率性 2024-08-05 20:33:27

我不使用推送通知,所以我不知道推送通知的确切工作原理。 但是,我会尝试通过让程序的主要方法假装已发布通知(如果可能)来模拟接收推送通知,或者从 applicationDidFinishLaunching: 方法中调用 application:didFinishLaunchingWithOptions: UIApplicationDelegate 方法。

HTH - 干杯,达安

I'm not working with push notifications, so I don't know the exact working of push notifications. However, I'd try mimicking the receipt of a push notification by letting the main method of your program pretend a notification was posted if possible, or calling the application:didFinishLaunchingWithOptions: UIApplicationDelegate method from within the applicationDidFinishLaunching: method.

HTH - Cheers, Daan

梦回旧景 2024-08-05 20:33:27

在 Xcode 6 中:

  1. 使用 USB 将 iPhone 连接到 Macbook
  2. 通过点击 Xcode 菜单中的图标启动 iPhone 上的应用程序
  3. 调试 > > 附加到进程 > 选择您的应用程序

In Xcode 6:

  1. connect iPhone to Macbook with USB
  2. launch the app on the iPhone by tapping the icon
  3. In Xcode menu, Debug > Attach to Process > Pick your App
甜中书 2024-08-05 20:33:27

对于 Xcode 11 和 10,您可以执行以下操作:

  1. 选择方案选项。

  2. 选择编辑方案。

  3. 从左侧面板中选择“运行”选项

  4. 在启动部分中,选择等待可执行文件启动,然后关闭对话框。

  5. 构建并运行项目。 您现在可以通过点击应用程序图标或点击通知消息来启动应用程序。

For Xcode 11 and 10, you can do the following:

  1. Select Scheme option.

  2. Choose Edit Scheme.

  3. Select Run option from the left panel

  4. In the launch part, select wait for executable to be launched, then close the dialog.

  5. Build and run the project. You can now launch the app either by tapping the app icon, or by tapping on the notification message.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文