IOS Local Notifications

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.