iOS Local notifications

Source: Internet
Author: User

Today's project uses a message to push the first time to do this aspect of the content first recorded.

When a third-party Aurora push is configured in accordance with Aurora's documentation, the project uses

When there is a push, you will receive push notifications from the server in the following ways, as well as push message content.

-(void) Networkdidreceivemessage: (nsnotification *) notification {    *userinfo = [ Notification UserInfo];     *extras = userinfo[@ "extras"];    NSString     *type = extras[@ "type"];     // nsstring *content = [userInfo valueforkey:@ "content"];         [self handleremotenotification:userinfo];//get push content, invoke method to handle push }

Handle push to determine the current state of the app

- (void) Handleremotenotification: (Nsdictionary *) userinfo{if(userinfo[@"_j_msgid"] || userinfo[@"content"]) {uiapplicationstate State=[UIApplication sharedapplication].applicationstate; if(state==uiapplicationstateactive | | state==uiapplicationstateinactive) {//at the front desk[[Nsnotificationcenter Defaultcenter]postnotificationname:r7_fetchremotenotificationnotifyObject: nil Userinfo:userinfo]; Supernavigationcontroller*navctrl = (Supernavigationcontroller *) [UIApplication Sharedapplication].keywindow.rootviewcontroller; Supertabcontroller*tabctrl= (supertabcontroller*) Navctrl.rootviewcontroller;                        [Tabctrl Dealwithpushinfo:userinfo applicationstate:state]; if(state==uiapplicationstateinactive) {[Apservice Setbadge:0]; [[UIApplication Sharedapplication]setapplicationiconbadgenumber:0]; }        }        Else if(State==uiapplicationstatebackground) {//notifications push to the background_userinfo=UserInfo;        [Self addlocationremind];        } [Apservice Handleremotenotification:userinfo]; DLog (@"userinfo:%@", UserInfo); }}

- (void) Addlocationremind {globalsingle*single =[Globalsingle Sharedsingleinstace]; Nsinteger Discussdynamicnumber= [Single Numbertointwithkey:dynamicnumberkey] +1;    [Single Savenumberwith:discussdynamicnumber Key:dynamicnumberkey]; NSDate*date = [NSDate datewithtimeintervalsincenow:5]; Uilocalnotification*note =[[Uilocalnotification alloc] init]; Note.alertbody=@"a reminder from Neuqer"; Note.alertaction=@"reply";//note.alertlaunchimage = @ "discuss_selected";Note.applicationiconbadgenumber =1; Note.soundname=Uilocalnotificationdefaultsoundname; Note.firedate=date; [[UIApplication sharedapplication] schedulelocalnotification:note];}

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.