如何检测用户何时清除应用程序的通知 [英] How to detect when user clears your app's notification

查看:182
本文介绍了如何检测用户何时清除应用程序的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用有通知功能。当我收到通知时,我会在我的应用图标中显示徽章。

My app has notification feature. When I receive a notification I show a badge in my app icon.

据我所知,当我的应用在后台时,由于用户未在通知时点击通知中心,我的应用程序不知道它有通知。因此它无法更改徽章编号。

As I know, when my app is on background, since user does not clicks on the notification at notification center, my app does not know that it has a notification. So it can not change the badge number.

此主题也是如此:

Also from this topic: Detect when a user clears notification from the notification center

如果用户清除应用程序的通知,则应用程序无法检测到它。

If user clears the app's notification, the app can not detect it.

所以问题出在这里:

- 我的应用程序在后台

- 用户收到与应用程序相关的通知

- 应用程序将1号徽章添加到应用程序的图标

- 用户删除通知通知中心

- 应用程序永远不会理解通知已被删除,以便它可以删除徽章!!!

So the problem is here:
- My app is on background
- User receives a notification related to the app
- App adds a badge with number 1 to the app's icon
- User deletes the notification from notification center
- App never understands that notification has been removed so that it can remove the badge!!!

那么其他应用程序如何修复此问题问题?有什么解决办法吗?

So how other apps fix this problem? Is there any solution for this?

推荐答案

无法检查用户何时清除应用程序的通知。

There is no way to check when the user clears notifications for your app.

清除应用程序徽章的通常做法是用户查看应用程序中的适用内容(例如,消息应用程序中的消息),或者只是在下次清除徽章时如果这不适用,用户会打开您的应用,或者您无法轻松细分通知并将其与应用中的可查看内容相关联。

The usual practice for clearing the app badge is when the user has viewed the applicable content within your app (e.g. messages in a messaging app), or otherwise just clearing the badge the next time the user opens your app if this is not applicable, or you can't easily segment the notifications and connect them to viewable content in your app.

注意: 如果您的用户没有点按您的通知,那么您的应用无法找到其内容,也无法查看其内容。

Note: you should not be relying on the user tapping on your notifications in order to get their content. If your user doesn't tap your notification, your app has no way of ever finding out its content, or that it ever existed.

相反,当您的应用被打开时,它应该连接到您的服务器以下载更新的内容,然后您可以使用这些完整,准确的信息来根据需要更新您的应用徽章。请勿尝试从通知中提取内容。

Instead, when your app is opened, it should connect to your server to download updated content, then you can use this complete, accurate information to update your app badge as required. Do not try to fetch content from your notifications.

这篇关于如何检测用户何时清除应用程序的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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