问题
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:
- Cancel all notifications on app start
- Schedule notifications on app exit
- *When scheduling, add the notification info to a "Recents" list
- *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:
- Receive 4 notifications per day
- 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