Estoy intentando borrar la insignia "no leída" de mi aplicación con UILocalNotification
. Lógicamente se podría pensar que esto se haría mediante la creación de una instancia de applicationIconBadgeNumber
UILocalNotification
a 0. Pero esto no funciona, y la documentación para applicationIconBadgeNumber decir "El valor por defecto es 0, que significa" sin cambio “."Borrar insignia de aplicación con notificaciones locales
Entonces, ¿hay realmente ninguna manera de limpiar una insignia con las notificaciones locales una vez que se ha establecido
actualización:? Algunos simple código:.
-(void)applicationDidFinishLaunching
{
// Set the appication icon badge to 1 in 10 minutes, using a local notification so it works in the background:
// This works fine.
UILocalNotification *episodeNotification = [[UILocalNotification alloc] init];
episodeNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:(60 * 10)];
episodeNotification.timeZone = [NSTimeZone defaultTimeZone];
episodeNotification.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication] scheduleLocalNotification:episodeNotification];
[episodeNotification release];
// Clear the application icon badge in 20 minutes, again using a local notifcation so it works in the background:
// This doesn't work. According to the docs for local notification it's not supposed to
// because (applicationIconBadgeNumber = 0) means "Do not change the badge"
// I'm looking for an alternative if it exists.
UILocalNotification *clearEpisodeNotification = [[UILocalNotification alloc] init];
clearEpisodeNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:(60 * 20)];
clearEpisodeNotification.timeZone = [NSTimeZone defaultTimeZone];
clearEpisodeNotification.applicationIconBadgeNumber = 0;
[[UIApplication sharedApplication] scheduleLocalNotification:clearEpisodeNotification];
[clearEpisodeNotification release];
}
'... Pero esto no funciona, ...' ¿Qué pasa cuando se intenta establecer la insignia a cero? – Moshe
Cuando configuro la insignia en cero y se activa la notificación, no ocurre nada. Sigue mostrando con el mismo número que tenía antes. – peterjb
¿Podemos ver algunos códigos, por favor? – Moshe