UIApplication.applicationIconBadgeNumber does not update immediately
Originator: | SaagarJha28 | ||
Number: | rdar://31790032 | Date Originated: | 24-Apr-2017 10:30 AM |
Status: | Closed | Resolved: | 21-Jun-2017 04:02 PM |
Product: | iOS + SDK (Notifications) | Product Version: | iOS 10.3 [14E269] |
Classification: | Other Bug | Reproducible: |
Area: Notifications Summary: I'm trying to schedule a couple local notifications in a loop (see attached project). Each notification (which triggers immediately) is intended to increment the app's badge number. However, running this does not seem to increment it properly; if I schedule 5 notifications the badge becomes "1", not "5". The issue appears to be that there is a delay in the updating applicationIconBadgeNumber; putting any sort of delay (for example, a sleep or a breakpoint) will resolve the issue. Steps to Reproduce: (Faulty results) 1. Run the attached code. 2. Simulate a background fetch (select it from Xcode's "Debug" menu) 3. View the badge number. (Expected results) 4. Navigate to application(_:performFetchWithCompletionHandler:) in AppDelegate.swift. 5. Find the usleep line. 6. Uncomment it. 7. Run the steps 1-3. Expected Results: The application badge icon will increase by 1 each time. Actual Results: The application badge icon will end up as 1 (or some other small number). Version: iOS 10.3 [14E269] Notes: I apologize for the use of UINotification; I was too lazy to figure out how UserNotifications worked. I set the deployment target to 9.3 to get rid of the warnings. Configuration: iOS Simulator
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!