How does UIApplication cancelAllLocalNotifications work between app updates?

两盒软妹~` 提交于 2019-12-11 02:36:05

问题


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. Cancel all notifications on app start
  2. Schedule notifications on app exit
  3. *When scheduling, add the notification info to a "Recents" list
  4. *When scheduling, schedule only 1 notification per day (verified in logging statements in XCode before I disconnect my phone).

Now, this is what I'm experiencing:

  1. Receive 4 notifications per day
  2. Only 1 of the notifications shows up in my "Recents" list (which makes sense, because that's all I'm scheduling)

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.

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.

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.


回答1:


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?



来源:https://stackoverflow.com/questions/9538194/how-does-uiapplication-cancelalllocalnotifications-work-between-app-updates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!