+ (void)addLocalNotification:(int)year:(int)month:(int)day:(int)hours:(int)minutes:(int)seconds:(NSString*)alertSoundName:(NSString*)alertBody:(NSString*)actionButtonTitle:(NSString*)notificationID
llamar a este método con los parámetros y el uso de este
+ (void)addLocalNotification:(int)year:(int)month:(int)day:(int)hours:(int)minutes:(int)seconds:(NSString*)alertSoundName:(NSString*)alertBody:(NSString*)actionButtonTitle:(NSString*)notificationID {
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
//set the notification date/time
NSDateComponents *dateComps = [[NSDateComponents alloc] init];
[dateComps setDay:day];
[dateComps setMonth:month];
[dateComps setYear:year];
[dateComps setHour:hours];
[dateComps setMinute:minutes];
[dateComps setSecond:seconds];
NSDate *notificationDate = [calendar dateFromComponents:dateComps];
[dateComps release];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = notificationDate;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
// Set notification message
localNotif.alertBody = alertBody;
// Title for the action button
localNotif.alertAction = actionButtonTitle;
localNotif.soundName = (alertSoundName == nil) ? UILocalNotificationDefaultSoundName : alertSoundName;
//use custom sound name or default one - look here to find out more: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html%23//apple_ref/doc/uid/TP40008194-CH103-SW13
localNotif.applicationIconBadgeNumber += 1; //increases the icon badge number
// Custom data - we're using them to identify the notification. comes in handy, in case we want to delete a specific one later
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:notificationID forKey:notificationID];
localNotif.userInfo = infoDict;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
}
Gracias por tu respuesta, pero logré hacerlo de otro modo ... Funciona. Una pregunta ... ¿Es posible abrir la vista de notificación personalizada en lugar de la predeterminada y también me gustaría agregar un sonido personalizado que se agregó en mi proyecto si es posible ... +1 para su compatibilidad – GoCrazy
No puede mostrar una ventana emergente de notificación personalizada. Puede agregar un sonido personalizado, pero debe estar en el paquete de la aplicación. Por lo tanto, es imposible reproducir un sonido que la aplicación haya descargado de Internet. Solo puede reproducir sonidos del sistema o sonidos que haya importado a su aplicación antes de la compilación. De nada. Acepte la respuesta si cree que es correcta, para ayudar a los futuros usuarios a encontrar la solución a este problema. –
sí. eso es lo que estoy buscando ¿podría usted poder publicar algunos códigos para reproducir el sonido en el paquete de la aplicación que importó antes de la compilación, por favor – GoCrazy