分类: 系统运维
2016-12-12 21:22:59
pod 'HyphenateSDK', :git => ''
https://github.com/easemob/easeui_ios/tree/new_dev
最坑的报错如下
原因是因为里面有.c文件,一般情况下出现“Unknown type name”是头文件互相引用出现的,这里可以排除,由于源码使用是c\c++与oc混编,
考虑新的XCode编译文件类型导致的,尝试了几种方案,下面三种可以解决问题。解决方案:.c文件,将属性的 identity and type 改为Objective-C Source。
#pragma mark - setupEMSDK - (void)setupEMSDK { //AppKey:注册的AppKey,详细见下面注释。 //apnsCertName:推送证书名(不需要加后缀),详细见下面注释。 EMOptions *options = [EMOptions optionsWithAppkey:EMSDKAppKey]; options.enableConsoleLog = NO; options.apnsCertName = EMSDKApnsCertName; [[EMClient sharedClient] initializeSDKWithOptions:options]; [[EMClient sharedClient] addDelegate:self delegateQueue:nil]; EMError *error1 = [[EMClient sharedClient] registerWithUsername:@"test" password:@"123456"]; if (error1==nil) { NSLog(@"注册成功"); }else { MMHLog(@"注册失败"); } EMError *error = [[EMClient sharedClient] loginWithUsername:@"test" password:@"123456"]; if (!error) { MMHLog(@"登录成功"); } else { MMHLog(@"登录失败"); } } - (void)applicationWillResignActive:(UIApplication *)application { } //APP进入后台 - (void)applicationDidEnterBackground:(UIApplication *)application { [[EMClient sharedClient] applicationDidEnterBackground:application]; } // APP将要从后台返回 - (void)applicationWillEnterForeground:(UIApplication *)application { [[EMClient sharedClient] applicationWillEnterForeground:application]; }
或者后台新建用户
如果有用户登录则变成绿色状态
EMError *error = [[EMClient sharedClient] loginWithUsername:@"test" password:@"123456"]; if (!error){ [[EMClient sharedClient].options setIsAutoLogin:YES]; }