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