Add local message notifications to your app using Uilocalnotification

Source: Internet
Author: User

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

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.