iOS 推送通知 - 单击应用程序图标而不是通知时如何获取通知数据 [英] iOS Push Notification - How to get the notification data when you click on the app icon instead of notification

查看:29
本文介绍了iOS 推送通知 - 单击应用程序图标而不是通知时如何获取通知数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似于这个问题:我如何访问applicationDidBecomeActive 上的远程推送通知数据?

但不同的是,当您处于applicationDidBecomeActive如果您点击了应用图标而不是推送通知时,您如何访问通知数据.>

流程是:如果你点击推送通知然后didReceiveRemoteNotification会被触发,但是如果你点击原来的应用程序图标,只有applicationDidBecomeActive 将被触发,didReceiveRemoteNotification 不会被调用.

我正在寻找后一种情况,所以我如何访问推送通知数据.

(两种情况都假设应用程序在后台并且尚未终止.)

解决方案

您无法通过从主屏幕启动应用程序来获取远程推送负载.

如果推送数据对应用使用很重要,请在应用启动后从您的服务器加载它.

Similar to this question: How do I access remote push notification data on applicationDidBecomeActive?

But the different is how can you access the notification data when you are inapplicationDidBecomeActive and if you have clicked on the app icon instead of the push notification.

The flow is: If you click on the push notification then didReceiveRemoteNotification will be triggered, but if you click on the original app icon, only applicationDidBecomeActive will be triggered and didReceiveRemoteNotification will not be called.

I am looking for the later case so how can I access the push notification data.

(Both case assuming the app is in background and not killed yet.)

解决方案

You can't get remote push payload by launching app from homescreen.

If the push data is important for app use, load it from your server after app launched.

这篇关于iOS 推送通知 - 单击应用程序图标而不是通知时如何获取通知数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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