收到推送通知,而在后台 [英] Receiving Push Notifications while in background

查看:172
本文介绍了收到推送通知,而在后台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是覆盖在很多地方,但我不知道这一点。我用飞艇城市的推送通知。一切似乎除了罚款时,我的应用程序在后台 - didReceiveRemoteNotification 是没有得到调用。我能够正确地处理邮件 - 当在前台它的工作原理。而我能够,如果消息从通知中心抽头获得从启​​动选项的消息。但是,当在后台运行,它发送一个消息 - iOS设备会显示警告 - didReceiveRemoteNotification 不叫。当我点击我的应用程序图标(而不是从通知中心内)应用程序来到前台,我不知道该通知是present。任何想法?

I know this is covered in a lot of places, but I cannot figure this out. I use Urban Airship for push notifications. Everything seems to be fine except that when my app is in the background - didReceiveRemoteNotification is not getting called. It works when in the foreground - I am able to properly process messages. And I am able to get to messages from launch options if message is tapped from notifications center. But when in the background, a message it send - iOS displays the alert - didReceiveRemoteNotification is not called. When I tap on my Application icon (not from within notification center) the app comes to the foreground and I have no idea the notification is present. Any ideas?

推荐答案

从APNS编程指南:

让我们回顾一下可能出现的情况时操作提供了一个
  本地通知或用于应用程序的远程的通知。

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

当应用程序没有在运行,则通知被传递
  前景。在这种情况下,系统presents通知,
  显示警告,徽章图标,也许播放声音。

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.

由于$ P $的结果psented通知,用户点击操作按钮
  的警报或抽头(或点击)的应用程序图标。如果操作
  按钮被窃听(运行iOS的设备上),系统启动
  应用程序和应用程序调用其委托的
  应用:didFinishLaunchingWithOptions:方法中(如果实现的话);它
  通过在通知有效载荷(用于远程通知)或
  本地通知对象(本地通知)。

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).

如果应用程序图标被窃听的设备上运行iOS,应用程序
  调用同样的方法,,但配料没有关于信息
  通知

If the application icon is tapped on a device running iOS, the application calls the same method, but furnishes no information about the notification.

我相信最后一句话描述你的情况,并解释了为什么您的应用程序获取没有关于通知信息。

I believe the last sentence describes your case, and explains why your application gets no information about the notification.

这篇关于收到推送通知,而在后台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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