Operation Process
1. Receiving Notifications
2. Register to send notifications
Usage: Reminder time, Alarm clock
Receive local notifications (implemented in Appdelegate)
-(void) Application: (UIApplication *) application didreceivelocalnotification: (uilocalnotification *) notification{
Actions after receiving a notification
Uialertview *aler = [[Uialertview alloc]initwithtitle:notification.alerttitle Message:notification.alertBody Delegate:self cancelbuttontitle:@ "OK" otherbuttontitles:nil, nil];
[Aler show];
}
Registration, method of sending notifications
-(void) pushnotfation{
Method of initial local notification
Uilocalnotification *not =[[uilocalnotification Alloc]init];
Not.firedate =[nsdate Datewithtimeintervalsincenow:10];
Set the title of the notification
Not.alerttitle = @ "Time to";
Set the contents of a notification
Not.alertbody = @ "Get Up and Knock code";
Delivering content through notifications
Not.userinfo = @{@ "key": @ "value"};
Set the number shown on the red dot above the app icon
Not.applicationiconbadgenumber = 1;
Interval to send
Not.repeatinterval =kcfcalendarunitmonth;
/*
Nscalendarunitera = Kcfcalendarunitera, a century
Nscalendarunityear = Kcfcalendarunityear, one year
Nscalendarunitmonth = Kcfcalendarunitmonth, one months
Nscalendarunitday = Kcfcalendarunitday, day
Nscalendarunithour = Kcfcalendarunithour, when
Nscalendarunitminute = Kcfcalendarunitminute, min
Nscalendarunitsecond = Kcfcalendarunitsecond, sec
Nscalendarunitweekday = Kcfcalendarunitweekday, a week
Nscalendarunitweekdayordinal = Kcfcalendarunitweekdayordinal,
*/
Registration Notice
if ([[UIApplication sharedapplication] Respondstoselector: @selector (registerusernotificationsettings:)]) {[[ UIApplication sharedapplication]registerusernotificationsettings:[uiusernotificationsettings settingsForTypes: uiusernotificationtypebadge| Uiusernotificationtypealert Categories:nil]];
}
Not.soundname= Uilocalnotificationdefaultsoundname;
Send Notifications
[[UIApplication Sharedapplication]schedulelocalnotification:not];
uiusernotificationtypebadge| Number of hints within the circle
uiusernotificationtypesound| The sound of the notification prompt
uiusernotificationtypenone|
Uiusernotificationtypealert Vibration
}
IOS Local Notifications