In the iOS8 system, adding this sentence is to allow users to send local notifications
-(BOOL) Application: (uiapplication *) application didfinishlaunchingwithoptions: ( Nsdictionary *) launchoptions {
if ([uiapplication instancesrespondtoselector:@selector( Registerusernotificationsettings:)]) {
[application registerusernotificationsettings: Uiusernotificationtypealert| Uiusernotificationtypebadge| Uiusernotificationtypesound categories: nil
}
//Override point for customization after application launch.
return YES;
}
Cancel Notification
-(void) Application: (uiapplication *) application didreceivelocalnotification: ( Uilocalnotification *) notification
{
NSString *pathstring = [[NSBundle mainbundle] pathforresource:@ " tick - regaling " oftype:@ "MP3"];
Avaudioplayer *avaudio = [[Avaudioplayer alloc] Initwithcontentsofurl:[[nsurl alloc] initfileurlwithpath:pathstring ] Error:nil];
Avaudio.delegate = self;
[Avaudio play];
application. Applicationiconbadgenumber = 0;
//[Avaudio release];
}
Register a notification
uilocalnotification *notification=[[uilocalnotification alloc]init];
if (notification!=Nil)
{
nsdate *now = [nsdate date];
// from now on, notify after ten seconds
Notification. firedate=[now datebyaddingtimeinterval: 50];
// use local time zone
notification. TimeZone=[nstimezone defaulttimezone];
// notification of repeated prompt units, which can be days, weeks, months
Notification.repeatinterval = Nscalendarunitcalendar;
Notification. alertbody=@ "1111";
// notification tones use the default
notification. Soundname=uilocalnotificationdefaultsoundname;
notification.alertaction =@ " you 1111 Span style= "Line-height:27px;color:rgb (180,38,26);" > ",
// This notification to the time when you display the number in the upper right corner of your application.
Notification. Applicationiconbadgenumber = 1;
add Key this key
*dict =[ nsdictionary Dictionarywithobjectsandkeys @ "MM" @ "Nfkey" nil
[Notification Setuserinfo:d ICT];
// Start this notification
[[uiapplication sharedapplication] schedulelocalnotification: notification];
}
This article is from the "11204872" blog, please be sure to keep this source http://11214872.blog.51cto.com/11204872/1754488
IOS Local Notifications