Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Seems to me that the <code>applicationIconBadgeNumber</code> is set “at the same time” as the delegate method is being called, instead of before or after, since setting a breakpoint in the delegate method seems to update the badge to the number you pretend.</p> <p>So, first (ugly) solution:</p> <pre><code>- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 125*NSEC_PER_MSEC); dispatch_after(popTime, dispatch_get_main_queue(), ^{ application.applicationIconBadgeNumber = 333; }); } </code></pre> <p>(125ms seems to do the trick).</p> <p>The second solution I though did not work out. Since <code>applicationIconBadgeNumber</code> is <code>readwrite</code> for <code>UILocalNotification</code> I tried to modify that on the fly… but it didn’t work.</p> <p>The third solution seems to work, and seems to be clear enough.</p> <pre><code>- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { [application cancelLocalNotification:notification]; application.applicationIconBadgeNumber = 333; } </code></pre> <p>(I will recommend checking the <code>application.applicationState</code> before doing that, though)</p> <p>The final solution is what you comment in your last paragraph: simply set the <code>applicationIconBadgeNumber</code> in <code>applicationWillResignActive:</code> to the correct value. As far as I can see, the badge number cannot be seen while the app is in foreground.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload