iOS8 message Shortcut processing-No input box

Source: Internet
Author: User

if (isiOS8)

{

Remote Push registration for iOS8

Nsset *set = nil;

#if 1

1. Create a message above the action to be added (the form of the button is displayed)

Uimutableusernotificationaction *action = [[Uimutableusernotificationaction alloc] init];

Action.identifier = @ "action";//the indicator of the button

[Email protected] "Accept";//The title of the button

Action.activationmode = uiusernotificationactivationmodeforeground;//Start the program when clicked

action.authenticationrequired = YES;

Action.destructive = YES;

Uimutableusernotificationaction *action2 = [[Uimutableusernotificationaction alloc] init]; Second button

Action2.identifier = @ "Action2";

[Email protected] "Reject";

Action2.activationmode = uiusernotificationactivationmodebackground;//When clicked does not start the program, in the background processing

action.authenticationrequired = yes;//need to be unlocked for processing if Action.activationmode = Uiusernotificationactivationmodeforeground; the attribute is ignored;

Action.destructive = YES;

2. Create a Category collection of actions (buttons)

Uimutableusernotificationcategory *category = [[Uimutableusernotificationcategory alloc] init];

Category.identifier = @ "alert";//the only indication of this set of actions

[Category Setactions:@[action,action2] Forcontext: (uiusernotificationactioncontextminimal)];

//

set = [Nsset setwithobjects:category, Nil];

Remote notification test message body: {"APS": {"alert": "Incoming call", "Sound": "Default", "badge": 1, "category": "Alert"}}

"Category": "alert" must correspond to Category.identifier = @ "alert";

Local notification Test

Uilocalnotification *notification = [[Uilocalnotification alloc] init];

Notification.firedate=[nsdate datewithtimeintervalsincenow:15];

Notification.timezone=[nstimezone Defaulttimezone];

[Email protected] "quick reply to test push";

Notification.category = @ "alert";

[[UIApplication sharedapplication] schedulelocalnotification:notification];

#endif

[[UIApplication sharedapplication] registerusernotificationsettings: [uiusernotificationsettings Settingsfortypes: (Uiusernotificationtypesound | Uiusernotificationtypealert | Uiusernotificationtypebadge) Categories:set];

[[UIApplication sharedapplication] registerforremotenotifications];

}else

{

  iOS8 previous remote Push registration

Uiremotenotificationtype Apn_type = (uiremotenotificationtype) (uiremotenotificationtypealert| uiremotenotificationtypesound| Uiremotenotificationtypebadge);

[[UIApplication sharedapplication] registerforremotenotificationtypes:apn_type];

}

}

-(void) Application: (UIApplication *) application Handleactionwithidentifier: (NSString *) identifier Forremotenotification: (nsdictionary *) userInfo Completionhandler: (void (^) ()) Completionhandler

{

When the app is not launched, received the server push message , the drop-down message will have a quick Reply button, click the button after the call method, according to identifier to determine which button to click

}

-(void) Application: (UIApplication *) application Handleactionwithidentifier: (NSString *) identifier Forlocalnotification: (uilocalnotification *) notification Completionhandler: (void (^) ()) Completionhandler

{

In the non-user interface when the local message , the drop-down message will have a quick reply to the button, click on the button to invoke the method, according to identifier to determine which button to click, notification for the message content

NSLog (@ "%@----%@", identifier,notification);

Completionhandler ();//finish the message and make sure to call this code block

}

iOS8 message Shortcut processing-No input box

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.