获取的推送通知自定义的有效载荷,而应用程序正在运行的背景 [英] Get custom payload of push notification while app is running background

查看:233
本文介绍了获取的推送通知自定义的有效载荷,而应用程序正在运行的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿任何人可以告诉如何获得推送通知的自定义负载时,应用程序是在后台?

Hey can anybody tell how to get custom payload of push notification when app is in background?

如果您的应用程序在后台运行,您会收到一个推送通知和用户水龙头的应用程序查看,在应用程序启动和的application:didFinishLaunchingWithOptions:将被调用。在这种情况下,我们可以从 USERINFO 字典通过 UIApplicationLaunchOptionsRemoteNotificationKey 访问自定义通知的有效载荷。

If your app is in the background and you receive a push notification and the user taps app "View", the application is launched and application:didFinishLaunchingWithOptions: would get called. In this case we can access custom notification payload via UIApplicationLaunchOptionsRemoteNotificationKey from userInfo dictionary.

如果您的应用程序在后台运行,您会收到一个推送通知和用户水龙头的应用程序图标,它带来的应用前景。

If your app is in the background and you receive a push notification and the user taps app icon, it brings the application to the foreground.

当发生这种情况,只有 applicationDidEnterForeground:被调用,并且没有办法访问推送通知的有效载荷

When that happens, only applicationDidEnterForeground: is called, and there is no way to access the payload of the push notification.

我的要求是为徽章只登记,不警惕所以没有查看按钮,当用户在后台收到通知启动应用程序。当用户收到通知,并应用在后台,用户点击应用程序图标 applicationDidEnterForeground:被调用。所以我们没有办法访问 launchOptions 字典或 USERINFO 从那里我们可以得到通知有效载荷的字典。

My requirement is to register for Badge only, no alert so no 'View' button to launch app when user receives notification in background. When user receives notification and application is in background, user taps app icon applicationDidEnterForeground: is called. So we have no way to access launchOptions dictionary or userInfo dictionary from where we can get notification payload.

我失去了一些东西在这里?

Am I missing something here?

推荐答案

应用程序:didReceiveRemoteNotification:当用户点击在状态栏通知,如果下拉叫你应用程序在后台运行。 href=\"http://stackoverflow.com/questions/3167614/ios-handling-pushed-notifications-with-apns\">链接你的的。

application:didReceiveRemoteNotification: is called when the user taps on the notification in the statusbar drop down if your app is running in the background. The link you referred to in your answer explains how to use it.

编辑:
对不起,我误解你的问题(错过了你的徽章,只是在做)。随意投下来我:(

Sorry, I misunderstood your question (missed that you were doing badge-only). Feel free to down vote me :(

这篇关于获取的推送通知自定义的有效载荷,而应用程序正在运行的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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