一、环信集成
使用Cocopods导入:
pod 'EaseUI', :git => 'https://github.com/easemob/easeui-ios-hyphenate-cocoapods.git'
pod 'Hyphenate'
二、初始化SDK
//AppKey:注册的AppKey,详细见下面注释。
//apnsCertName:推送证书名(不需要加后缀),详细见下面注释。
EMOptions *options = [EMOptions optionsWithAppkey:IMAPPKEY];
options.apnsCertName = @"istore_dev";
[[EMClient sharedClient] initializeSDKWithOptions:options];
//初始化EaseUI (可以与初始化SDK二选一,本人都写了,以防万一)
[[EaseSDKHelper shareHelper] hyphenateApplication:application
didFinishLaunchingWithOptions:launchOptions appkey:IMAPPKEY apnsCertName:@"qy"
otherConfig:@{kSDKConfigEnableConsoleLogger:[NSNumber numberWithBool:YES]}];
三、环信登录
在登录环信之前要登录自己的APP,这样后台要和环信后台交互(可以让后台自动注册环信),在APP登录成功时返回用户名和密码,用于后期的环信登录
//登录环信
EMError *error1 = [[EMClient sharedClient] loginWithUsername:[[NSUserDefaults standardUserDefaults] objectForKey:@"uuid"] password:[[NSUserDefaults standardUserDefaults] objectForKey:@"password"]];
NSLog(@"ppppppperror1:%d",error1.code);
//error1.code=0,则登录成功
//自动登录
[[EMClient sharedClient].options setIsAutoLogin:YES];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//AppKey:注册的AppKey,详细见下面注释。
//apnsCertName:推送证书名(不需要加后缀),详细见下面注释