Used code, directly affixed to the
1Uilocalnotification *notification =[[Uilocalnotification alloc] init];2 if(notification!=Nil) {3NSDate *now = [nsdateNew];4 //notice from now on, 10 seconds later5Notification.firedate=[now Addtimeinterval:Ten];6 //use local time zone7Notification.timezone=[Nstimezone Defaulttimezone];8notification.alertbody=@"Top tip content, notification time is up";9 //notification tones use the defaultTenNotification.soundname=Uilocalnotificationdefaultsoundname; OneNotification.alertaction=nslocalizedstring (@"you lock the screen, it's time to call .", nil); A //this notification to the time when your app displays the number in the upper right corner. -Notification.applicationiconbadgenumber =1; -Nsdictionary *dic = [Nsdictionary dictionarywithobject:@"name"Forkey:@"Key"]; theNotification.userinfo =dic; - //Start this notification - [[UIApplication sharedapplication]schedulelocalnotification:notification]; -}
Note that after iOS8 need to register the message push service can be, the specific implementation is in the Appdelegate
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions
method, you can call the following method directly
1 if ([uiapplication instancesrespondtoselector: @selector (registerusernotificationsettings:)]) {2 3 settingsfortypes:uiusernotificationtypealert| uiusernotificationtypebadge| 4 Categories:nil]]; 5 }
Add local message notifications to your app using uilocalnotification