0

请建议我客观的 ​​c 代码,以便在推送通知到来时将应用程序从后台带到前台,而无需任何用户交互。

4

3 回答 3

3

不幸的是,这是不可能的,因为通知来了,即使没有用户交互,您的应用程序也会自动启动。

随着推送通知的到来,它由操作系统处理。

如果在应用程序未运行时收到应用程序的通知,则设备会提醒用户该应用程序有数据等待它。

那么这意味着用户必须与设备交互。

来自苹果文档。

When the operating system delivers push notification (iOS or OS X) and the target application is not running in the foreground, it presents the notification (alert, icon badge number, sound). If there is a notification alert and the user taps or clicks the action button (or moves the action slider), the application launches and calls a method to pass in the local-notification object or remote-notification payload. If the application is running in the foreground when the notification is delivered, the application delegate receives a local or push notification.

就这样。

我希望它清楚你。

于 2013-02-16T12:04:39.490 回答
1

我不认为它可能。一旦推送通知到来,操作系统本身会处理并显示通知,如果它为您的应用程序启用。然后从通知中,如果您要访问应用程序,则会触发 didReceiveRemotenotification 回调。谢谢。

于 2013-02-16T11:53:38.263 回答
0

这是可能的,但需要越狱的 iPhone 并挂钩推送通知接收器以在收到通知时启动您的应用程序。

如果你的目标是 App Store,你就做不到。

于 2013-02-16T12:53:58.967 回答