友盟消息推送服务器demo,友盟消息推送总结
分享的文章連接
1? http://blog.csdn.net/shenjie12345678/article/details/41120637
2;http://dev.umeng.com/push/ios/integration
重點解析:
1:如何獲得友盟推送的AppKey?
1.1登陸到友盟的消息推送界面——>添加應用,出現如下界面
其中開發證書是指:在鑰匙串中導出的Development的證書
生產證書是指:在鑰匙串中導出的Production生產的證書
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;//當點擊的時候啟動程序
UIMutableUserNotificationAction *action2 = [[UIMutableUserNotificationAction alloc] init];? //第二按鈕
action2.identifier = @"action2_identifier";
action2.title=@"Reject";
action2.activationMode = UIUserNotificationActivationModeBackground;//當點擊的時候不啟動程序,在后臺處理
action2.authenticationRequired = YES;//需要解鎖才能處理,如果action.activationMode = UIUserNotificationActivationModeForeground;則這個屬性被忽略;
action2.destructive = YES;
UIMutableUserNotificationCategory *categorys = [[UIMutableUserNotificationCategory alloc] init];
categorys.identifier = @"category1";//這組動作的唯一標示
[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];
}
總結
以上是生活随笔為你收集整理的友盟消息推送服务器demo,友盟消息推送总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c++ 舞伴配对问题_R绘图:配对样本差
- 下一篇: 嵌入式linux组件,嵌入式Linux系