ios - 有一种方法可以在 ios 中捕获推送通知吗?

标签 ios iphone objective-c cordova

有没有办法在Ios中捕获推送通知?为了从外部应用程序(例如 asp.net 应用程序)接收包含某些内容的通知,而不向用户显示推送通知并获取有用的内容?

如果您也知道在phonegap中执行此操作的方法,它对我也很有用。

谢谢!

最佳答案

如果应用程序在后台或未运行,您将无法捕获推送通知。

否则,如果应用程序在前台,当应用程序收到推送通知时,AppDelegate 的方法 application:didReceiveRemoteNotification: 将被调用,然后您可以使用推送中的信息做任何您想做的事情通知。

Let’s review the possible scenarios when the system delivers a local notification or a remote notification for an application.

The notification is delivered when the application isn’t running in the foreground. In this case, the system presents the notification, displaying an alert, badging an icon, perhaps playing a sound.

As a result of the presented notification, the user taps the action button of the alert or taps (or clicks) the application icon. If the action button is tapped (on a device running iOS), the system launches the application and the application calls its delegate’s application:didFinishLaunchingWithOptions: method (if implemented); it passes in the notification payload (for remote notifications) or the local-notification object (for local notifications).

If the application icon is tapped on a device running iOS, the application calls the same method, but furnishes no information about the notification . If the application icon is clicked on a computer running OS X, the application calls the delegate’s applicationDidFinishLaunching: method in which the delegate can obtain the remote-notification payload.

The notification is delivered when the application is running in the foreground. The application calls its delegate’s application:didReceiveRemoteNotification: method (for remote notifications) or application:didReceiveLocalNotification: method (for local notifications) and passes in the notification payload or the local-notification object.

请参阅documentation获取更多信息。

关于ios - 有一种方法可以在 ios 中捕获推送通知吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20663964/

相关文章:

ios - React Native 中的 Fetch(或 Axios)不适用于 iOS 应用程序的博览会

ios - 无法识别无法识别的选择器错误的原因

ios - 使用 HTML5 <video> 标签,在 iOS 7 及更低版本中单击图像时播放视频,但在 iOS 8.1 中,它在应用程序启动时播放

ios - 无法使用 NSFetchedResultsController 在 TableView Controller 中呈现数据

iphone - 作为掩码的 CGImageRef 和不是掩码的 CGImageRef 有什么区别?

ios - 来自容器 ViewController 的 UIPopOverPresentationViewController

iphone - 如何在iPhone中用动画画线

iphone - 在核心数据(Objective-C,iPhone,Xcode)中选择不同的值(2个或更多)

iphone - 处理 Objective-C 中的本地通知

c - Objective-C 和 C 的互操作性