UIApplication cancelAllLocalNotifications 如何在应用更新之间工作? [英] How does UIApplication cancelAllLocalNotifications work between app updates?

查看:65
本文介绍了UIApplication cancelAllLocalNotifications 如何在应用更新之间工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道cancelAllLocalNotifications 方法在UIApplication 上是如何工作的?我特别想知道 iOS 如何知道要取消什么.它通过 App ID 知道吗?还是以某种方式使用了应用程序的版本号?

Does anyone know how the cancelAllLocalNotifications method works on UIApplication? I'm wondering specifically how iOS knows what to cancel. Does it know by App ID? Or does it use the version number of the app somehow?

我现在遇到的通知比我预期的要多.这是工作流程:

What I'm experiencing right now is more notifications than I expect. This is the workflow:

  1. 取消应用启动时的所有通知
  2. 在应用退出时安排通知
  3. *安排时,将通知信息添加到最近"列表
  4. *安排时,每天只安排 1 个通知(在我断开手机连接之前在 XCode 中的日志记录语句中验证).

现在,这就是我所经历的:

Now, this is what I'm experiencing:

  1. 每天收到 4 条通知
  2. 只有 1 个通知显示在我的最近"列表中(这是有道理的,因为我只安排了这些)

以前,我每天的通知数量设置为 3.然后我更新了版本号(例如,从 1.1.0 到 1.1.1)以调用cancelAllLocalNotifications"方法.

Previously, I my # of notifications per day set to 3. Then I updated the version number (say, from 1.1.0 to 1.1.1) for the "cancelAllLocalNotifications" method was called.

因此,如果通知的取消以任何方式基于应用程序的版本/捆绑 ID,我将收到旧通知和新通知.

So, if the canceling of notifications is based upon the app's version/bundle ID in any way, I'm getting old notifications along with the new ones.

但是,如果不是,并且 iOS 知道取消从以前的 1.1.0 版本计划的通知,那么我不知道这些额外的通知来自哪里.

However, if it is not, and iOS knows to cancel notifications scheduled from the previous version 1.1.0, then I have no idea where these additional notifications are coming from.

推荐答案

我相信本地和远程通知是基于 App ID (AppleID + BundleID).因此,无论版本如何,您都会收到通知.我可以看到支持和反对这个实现的论据.

I believe that Local and Remote notifications are based upon the App ID (AppleID + BundleID). Therefore, regardless of version, you are going to get notifications. I can see the argument both for and against this implementation.

您是否需要一些策略来处理这个...功能?

Did you need some strategies for dealing with this... functionality?

这篇关于UIApplication cancelAllLocalNotifications 如何在应用更新之间工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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