分享的文章連接
1? http://blog.csdn.net/shenjie12345678/article/details/41120637
2耀找;http://dev.umeng.com/push/ios/integration
重點(diǎn)解析:
1:如何獲得友盟推送的AppKey撑瞧?
1.1登陸到友盟的消息推送界面——>添加應(yīng)用,出現(xiàn)如下界面
其中開發(fā)證書是指:在鑰匙串中導(dǎo)出的Development的證書
生產(chǎn)證書是指:在鑰匙串中導(dǎo)出的Production生產(chǎn)的證書
2:下載消息推送的SDK
3: 代碼? 在AppDelegate.h添加
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self pushNotification:launchOptions];
return YES;
}
#pragma mark====消息推送配置
-(void)pushNotification:(NSDictionary*)launchOptions{
[UMessage startWithAppkey:@"5578f54967e58e03ad008619" launchOptions:launchOptions];
//#define IS_iOS8 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 ? YES : NO)
if(IS_iOS8)
{
//register remoteNotification types (iOS 8.0及其以上版本)
UIMutableUserNotificationAction *action1 = [[UIMutableUserNotificationAction alloc] init];
action1.identifier = @"action1_identifier";
action1.title=@"Accept";
action1.activationMode = UIUserNotificationActivationModeForeground;//當(dāng)點(diǎn)擊的時候啟動程序
UIMutableUserNotificationAction *action2 = [[UIMutableUserNotificationAction alloc] init];? //第二按鈕
action2.identifier = @"action2_identifier";
action2.title=@"Reject";
action2.activationMode = UIUserNotificationActivationModeBackground;//當(dāng)點(diǎn)擊的時候不啟動程序硅卢,在后臺處理
action2.authenticationRequired = YES;//需要解鎖才能處理,如果action.activationMode = UIUserNotificationActivationModeForeground;則這個屬性被忽略渴丸;
action2.destructive = YES;
UIMutableUserNotificationCategory *categorys = [[UIMutableUserNotificationCategory alloc] init];
categorys.identifier = @"category1";//這組動作的唯一標(biāo)示
[categorys setActions:@[action1,action2] forContext:(UIUserNotificationActionContextDefault)];
UIUserNotificationSettings *userSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert
categories:[NSSet setWithObject:categorys]];
[UMessage registerRemoteNotificationAndUserNotificationSettings:userSettings];
} else{
//register remoteNotification types (iOS 8.0以下)
[UMessage registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound
|UIRemoteNotificationTypeAlert];
}
//是否開啟消息推送
[UMessage setLogEnabled:YES];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[UMessage registerDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
NSLog(@"userInfo == %@",userInfo);
NSString *message = [[userInfo objectForKey:@"aps"]objectForKey:@"alert"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:message delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];
[alert show];
}