日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

友盟消息推送服务器demo,友盟消息推送总结

發(fā)布時(shí)間:2025/3/12 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 友盟消息推送服务器demo,友盟消息推送总结 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

分享的文章連接

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)如下界面

其中開(kāi)發(fā)證書(shū)是指:在鑰匙串中導(dǎo)出的Development的證書(shū)

生產(chǎn)證書(shū)是指:在鑰匙串中導(dǎo)出的Production生產(chǎn)的證書(shū)

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)擊的時(shí)候啟動(dòng)程序

UIMutableUserNotificationAction *action2 = [[UIMutableUserNotificationAction alloc] init];? //第二按鈕

action2.identifier = @"action2_identifier";

action2.title=@"Reject";

action2.activationMode = UIUserNotificationActivationModeBackground;//當(dāng)點(diǎn)擊的時(shí)候不啟動(dòng)程序,在后臺(tái)處理

action2.authenticationRequired = YES;//需要解鎖才能處理,如果action.activationMode = UIUserNotificationActivationModeForeground;則這個(gè)屬性被忽略;

action2.destructive = YES;

UIMutableUserNotificationCategory *categorys = [[UIMutableUserNotificationCategory alloc] init];

categorys.identifier = @"category1";//這組動(dòng)作的唯一標(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];

}

//是否開(kāi)啟消息推送

[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];

}

總結(jié)

以上是生活随笔為你收集整理的友盟消息推送服务器demo,友盟消息推送总结的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。