关于友盟推送

这是一篇关于友盟推送的集成

1.首先,需要创建appid,创建的时候需要勾选push Notifications , bundeID要和工程名字保持一致,然后点击continue,之后继续创建,首先是开发证书,选中在电脑中自己导出的cer文件,cer文件的创建从钥匙串中导出,创建一个cer文件,然后点击上传,成功后可以下载他的开发者证书,把他存入本地,然后从钥匙串中导出p12文件,生产者证书一样的道理

2.创建友盟的账号和密码,然后创建应用,讲开发者证书和生产者证书p12上传到应用中,服务器就如果测试的话就填自己的ip地址,公司的服务器就填公司的,创建之后就得到他的appkey和appscres,记录下来,下载最新的SDK,导入UMessage_Sdk_x.x.xh中的文件

3.创建工程,如果是ios9.0以上的用户需要先配置一下

详情去看:http://dev.umeng.com/push/ios/ios9filter

保持bundID和创建的appid时候bundID一致

4.导入

#import "UMessage.h"

#define APPKEY @"572cb4d867e58ed140000052"

#define APPSecret @"yldutas9tnmbcd0hbfkkfqjidgbdrqzy"

#define UMSYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

#define _IPHONE80_ 80000


然后在在下面设置

[UMessage startWithAppkey:APPKEY launchOptions:launchOptions];

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= _IPHONE80_

if(UMSYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))

{

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

}

#else

//register remoteNotification types (iOS 8.0以下)

[UMessage registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge

|UIRemoteNotificationTypeSound

|UIRemoteNotificationTypeAlert];

#endif

//for log

[UMessage setLogEnabled:YES];


下面设置他的代理获取他的token

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

{

[UMessage registerDeviceToken:deviceToken];

}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

{

[UMessage didReceiveRemoteNotification:userInfo];

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • deviceToken 错误,友盟推送要求的格式不允许有符号,空格,而且 有长度限制,添加测试机的时候应处理过后再...
    六朝阅读 7,811评论 0 0
  • 分享的文章连接 1 http://blog.csdn.net/shenjie12345678/article/de...
    Hris阅读 4,894评论 0 0
  • 1.创建应用 在友盟有账号的情况下(没有的请自行创建),创建应用之前需要去苹果开发者网站申请一个App ID和配置...
    赵亦晨阅读 8,560评论 7 3
  • 一 本地推送 使用 UIApplication 注册一个通知 //快捷回复 UIMutableUserNotif...
    筱x阅读 5,107评论 0 0
  • 好久没做推送了,最近越到了一些坑,但顺利搞定,简单说下步骤 一. 首先简单说下证书(注意所以推送相关证书尽量用项目...
    skma阅读 4,962评论 10 1

友情链接更多精彩内容