iOS版 - 处理与APNS推通知 [英] iOS - Handling pushed notifications with APNS

查看:173
本文介绍了iOS版 - 处理与APNS推通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑到我收到我的iPhone推送通知。

Considering that I receive a pushed notification on my iPhone.

会发生什么:


  1. 如果在应用程序启动:有没有办法得到有效载荷?我会看到我的屏幕上的通知?

  2. 如果应用程序没有启动,有没有办法让有效载荷?

THX你的答案

推荐答案

首先推送通知都没有强,如果你只是让一个通知,坐的时间足够长(如手机关掉了很多天),它会得到丢弃。你需要做一些定制的后端处理,以坚持发送通知的内容。

First of all push notifications are not "strong", if you simply let a notification sit for long enough (e.g. phone turned off for many days) it will get discarded. You need to do some custom back-end processing to persist the content sent in notifications.

UIApplicationDelegate 的协议有的application:didFinishLaunchingWithOptions:。如果您的应用程序被用户敲击在警告的右键推出的推送通知,绑定方法调用的 launchOptions 词典将包含关于该通知信息;如果您的应用程序已经在运行,然后应用程序:didReceiveRemoteNotification:(也委托协议)将被调用,而不是

In the UIApplicationDelegate protocol there’s application:didFinishLaunchingWithOptions:. If your app is launched by the user tapping the right button in an alert of a push notification, the launchOptions dictionary bound to the method call will contain information regarding that notification; if your app is already running then application:didReceiveRemoteNotification: (also in the delegate protocol) will get called instead.

因此​​,


  • 如果该应用程序已启动,并在实施应用程序:didReceiveRemoteNotification:然后是你得到的有效载荷。否则,什么都不会发生。

  • If the application is started, and you implement application:didReceiveRemoteNotification: then yes you get the payload. Otherwise, nothing happens.

如果应用程序没有在该通知发出的时间开始,然后用户点击该通知的警报并启动您的应用,您的应用程序得到有效载荷,如果它实现应用程序中:didFinishLaunchingWithOptions:。否则,你什么也得不到。

If the application is not started at the time the notification is sent, then the user taps on the alert of the notification and launches your app, your app gets the payload if it implements application:didFinishLaunchingWithOptions:. Otherwise, you get nothing.

这篇关于iOS版 - 处理与APNS推通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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