IOS Local Notification Uilocalnotification

Source: Internet
Author: User

//Send Notifications
uilocalnotification *notification=[[uilocalnotification alloc] init];
    if(notification!=nil) {
nsdate *now=[nsdateNew];
Notification.firedate=[now Datebyaddingtimeinterval:Ten];//notify after 10 seconds
notification.repeatinterval=0;//cycle times, Kcfcalendarunitweekday once a week
Notification.timezone=[nstimezone Defaulttimezone];
notification.applicationiconbadgenumber=1; //Applied Red number
notification.soundname= Uilocalnotificationdefaultsoundname;//Sound, can be replaced by Alarm.soundname = @ "MYMUSIC.CAF"
//remove the following 2 lines without prompting the popup box
notification.alertbody=@"Notification Content";//prompt Message pop-up prompt box
notification.alertaction =@"Open"; //Prompt Box button
//notification.hasaction = NO;//If the extra button is displayed, the alertaction disappears when no

//nsdictionary *infodict = [nsdictionary dictionarywithobject:@ "somevalue" forkey:@ "Somekey"];
//notification.userinfo = infodict;//Add additional information
        
[[UIApplication sharedapplication] schedulelocalnotification:notification];
    }
[Notification release];

Cancel Notification

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions { /c3>
    
    //Override point for customization after application launch.
Application.applicationiconbadgenumber =0;
    //ADD The View controller ' s view to the window and display.
[window AddSubview:viewController.view];
[window makekeyandvisible];

    returnYES;
}
- (void) Application: (UIApplication *) application didreceivelocalnotification: (uilocalnotification *) Notification {
    //Click Open in the Prompt box
Application.applicationiconbadgenumber =0;
}
- (void) Applicationdidbecomeactive: (uiapplication *) application {
    //when the program is still running the day after Tomorrow
Application.applicationiconbadgenumber =0;
}

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.