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

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

问题描述

我知道这在很多地方都有涉及,但我无法弄清楚.我使用 Urban Airship 进行推送通知.一切似乎都很好,只是当我的应用程序在后台时 - didReceiveRemoteNotification 没有被调用.它在前台工作 - 我能够正确处理消息.如果从通知中心点击消息,我可以从启动选项获取消息.但是在后台时,它发送的消息 - iOS 显示警报 - didReceiveRemoteNotification 不会被调用.当我点击我的应用程序图标(不是在通知中心内)时,应用程序出现在前台,我不知道通知是否存在.有什么想法吗?

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 编程指南:

From the APNS programming guide :

让我们回顾一下当操作交付一个可能的场景应用程序的本地通知或远程通知.

Let’s review the possible scenarios when the operating 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.

作为显示通知的结果,用户点击操作按钮或点击(或单击)应用程序图标.如果行动点击按钮(在运行 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天全站免登陆