点击应用程序图标

点击应用程序图标

本文介绍了如何使用不同的用户操作(包括点击应用程序图标)捕获所有 iOS 推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Apple 指南:

As per the Apple guide:

作为显示通知的结果,用户点击警报的操作按钮或点击(或点击)应用程序图标.如果点击操作按钮(在运行 iOS 的设备上),系统启动应用程序,应用程序调用其委托的 application: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 的设备上点击应用程序图标,应用程序会调用相同的方法,但不提供有关通知的信息.如果在运行 Mac OS X 的计算机上单击应用程序图标,应用程序将调用委托的 applicationDidFinishLaunching: 方法,委托可以在该方法中获取远程通知负载."

If the application icon is tapped on a device running iOS, the application calls the same method, but furnishes no information about the notification . If the application icon is clicked on a computer running Mac OS X, the application calls the delegate’s applicationDidFinishLaunching: method in which the delegate can obtain the remote-notification payload."

我的问题是假设用户从供应商处收到 3-4 条推送通知,并且所有通知都存储在苹果的通知中心.如果用户点击通知警报,他/她可以轻松地在应用程序中获取通知数据.但是如果用户在 iPhone 上点击应用图标,如何获取之前所有通知的所有相关数据.

My question isSuppose user got 3-4 Push notifications from provider and all are stored in apple's notification center. If user tapped on notification alert, he/she can easily get the notification data in the app. But if user tapped app icon on iPhone, how to get all the data related of all previous notifications.

提前致谢!

推荐答案

您不能,您只会收到有关用于打开您的应用的通知的信息.

You can't, you will only receive information about the notification that was used to open your app.

因此,如果用户打开您的应用,并且您的应用有通知,您将无法在您的应用中检索它们.

So if a user opens your app, and your app has notifications, you will not be able to retrieve them from with in your app.

解决方法可能是跟踪服务器上的通知并在应用程序中处理此问题.因此,服务器会跟踪已读取的通知.Facebook 就是这样做的.

A work around could be to also keep track of notification on a server and handle this with in the app. Thus the server keeps track on which notification has been read. This is how Facebook does it.

这篇关于如何使用不同的用户操作(包括点击应用程序图标)捕获所有 iOS 推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 14:05