The use of local notifications is much easier than PUSH notifications, that needs to implement a server-side web app for sending PUSH notifications through Apple Push Notification (APN) service.
To use local notifications, you only have to instantiate NSLocalNotification class, set it's fire date and time, its message, sound and any other fields that you could need and schedule it in local notification scheduler, and iOS do the rest for you.
Here is a sample code
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = itemDate;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
// Set the action button
localNotif.alertAction = @”View”
//This sets the alert text to the current text in the textfield.
localNotif.alertBody = @"Charle's birthday";
//This sets the sound name of the notification.
localNotif.soundName = UILocalNotificationDefaultSoundName;
//You can also set the badge number of the application.
localNotif.applicationIconBadgeNumber = 1;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
I hope this could be useful for you, enjoy it!!
No comments:
Post a Comment