环信集成步骤

作者: CMD独白 | 来源:发表于2016-05-12 13:18 被阅读622次

    步骤如下:

    1、下载SDKhttp://www.easemob.com/download
    证书下载上传
    后期发送消息 需要推送发送的内容
    http://docs.easemob.com/doku.php?id=im:300iosclientintegration:10prepareforsdkimport

    1下载SDK.png

    2、导入下载好的SDK

    2.导入下载好的SDK.png

    3、添加依赖库

    CoreMedia.framework
    AudioToolbox.framework
    AVFoundation.framework
    MobileCoreServices.framework
    ImageIO.framework
    SystemConfiguration.framework
    libc++.dylib
    libresolv.dylib
    libz.dylib
    libstdc++.6.0.9.dylib
    libsqlite3.dylib

    添加-force_load
    target -> build settings -> 搜索other linker flags -> 双击other linker flags后边添加-force_load -> 将libHyphenateSDK.a拖到-force_load下边(出现10个警告)如果拖libHyphenateFullSDK.a文件 会出现4个错误
    注意:SDK不支持bitcode,向Build Settings → Linking(搜bit) → Enable Bitcode中设置NO。


    3.添加依赖库.png

    4、运行编译器,检查是否报错

    4.运行编译器,检查是否报错.png

    5、真机错误修复

    5.真机错误修复.jpg

    6.5、导入libiconv

    6.5导入libiconv.jpg

    6、导入EaseUI框架

    6.导入EaseUI框架.jpg

    7、导入静态库 运行后会有很多报错

    7.导入静态库 运行后会有很多报错.png

    8、添加PCH到工程

    8.添加PCH到工程.png

    9、将PCH文件修改成相对路径

    9.将PCH文件修改成相对路径.png

    10、注册环信

    10.注册环信.png

    11、实现单聊功能

    11.实现单聊功能.png

    注册环信

    1)导入头文件#import "EMSDK.h"
    (2)注册代码
    EMOptions *options = [EMOptions optionsWithAppkey:@"xuanyi#im"];
    options.apnsCertName = @"DDD";
    [[EMClient sharedClient] initializeSDKWithOptions:options];
    (3)用户注册
    EMError *error = [[EMClient sharedClient] registerWithUsername:@"ming" password:@"111"];
    (4)用户登录
    EMError *error = [[EMClient sharedClient] loginWithUsername:@"ming" password:@"111"];
    (5)添加好友
    《1》EMError *error = [[EMClient sharedClient].contactManager addContact:@"xiao" message:@"..."];
    《2》[[EMClient sharedClient].contactManager addDelegate:self delegateQueue:nil];
    《3》成功didReceiveAgreedFromUsername:
    《4》遭拒绝didReceiveDeclinedFromUsername:

    注意:
    如果项目中使用-ObjC有冲突,可以添加-force_load来解决, 添加-force_load:
    targets->build setting->other linker flags->添加-force_load->静态库拖动到他的下面,-force_load[空格]EaseMobSDK/lib/libHyphenateSDK.a(静态库的路径)。

    代码:

    • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      //AppKey:注册的appKey,详细见下面注释。
      //apnsCertName:推送证书名(不需要加后缀),详细见下面注释。
      EMOptions *options = [EMOptions optionsWithAppkey:@"chen0828#childrenstory"];
      options.apnsCertName = @"not";
      [[EMClient sharedClient] initializeSDKWithOptions:options];

      [[EaseSDKHelper shareHelper] easemobApplication:application
      didFinishLaunchingWithOptions:launchOptions
      appkey:@"chen0828#childrenstory"
      apnsCertName:@"not"
      otherConfig:@{kSDKConfigEnableConsoleLogger:[NSNumber numberWithBool:YES]}];
      return YES;
      }
      // App进入后台

    • (void)applicationDidEnterBackground:(UIApplication *)application
      {
      [[EMClient sharedClient] applicationDidEnterBackground:application];
      }

    // App将要从后台返回

    • (void)applicationWillEnterForeground:(UIApplication *)application
      {
      [[EMClient sharedClient] applicationWillEnterForeground:application];
      }

    相关文章

      网友评论

        本文标题:环信集成步骤

        本文链接:https://www.haomeiwen.com/subject/qrknlttx.html