Ahora les voy a compartir unas lineas de codigo para poder crear alertas/notificaciones locales desde una aplicacion en iOS:
// Creamos el objecto de la notificación
UILocalNotification *notification = [[UILocalNotification alloc] init] ;
// Fecha/Tiempo en el que se lanzara la notificación
notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:60];
// TimeZone
notification.timeZone = [NSTimeZone localTimeZone];
// Mensaje de la notificación
notification.alertBody = [NSString stringWithFormat: @"Mensaje interesante!"];
// Puedes pasar adicionalmente un Diccionario con valores.
notification.userInfo= [NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Some info"] forKey:@"information"];
// Posibilidad de repetir la notificacion
// notification.repeatInterval= NSCalendarUnitDay;
// Sonido de la notificacion
notification.soundName = UILocalNotificationDefaultSoundName;
//notification.soundName = @"sound.aif";
notification.applicationIconBadgeNumber = 0;
// Se ejecutara la notificacion en la fecha ingresada.
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
//Si desean ejecutar la notificacion al instante
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
Saludos!
Comentarios
Publicar un comentario