http://www.ox-holdings.com

环信老司机带你开发实时音视频,00)●5分钟集成环信移动客服+环信智能机器人全解析

摘要约请在座即时通信云服务端环信提供的公开学第15期:怎样用AI+深度学习落实录制美颜。环信简要介绍环信成立于二零一二年四月,是一家境内抢先的营业所级软件服务提供商,于二零一六年荣获“Gartner 二〇一六 Cool Vendor”。成品包蕴国内上线最初规模最大的即时通信云平台——环信即时通信云,甚至移动端最好履行的全媒体智能云客服平台——环信移动客服。参加会议办法点此链接步入报名:

摘要邀约加入即时通信云服务端环信提供的公开课第15期:环信老手带您付出实时音录像。引言作为客商服务世界的领军集团,环信以Web和应用软件为载体公布了视频客服产物。基于产业界超越的实时音录像通信技术,为访客及合营社客服职员提供双向的实时摄像交互作用工夫,援助摄像画面显得与重播,语音及文字同步在线畅通调换,画质清晰,低顺延。近些日子曾经大量应用于保险定损、在线教育、商品引导购物、医治触诊、远程业务办理、VIP服务等六大现象,消费者能够足不出门便可享用真人面前遭逢面VIP服务,帮助公司在增进客商体验的还要非常的大减少资金和晋升客性格很顽强在辛苦费劲或巨大压力面前不屈作用。此番公开学大家将邀约有11年音录像开拓经历的环信音视频老鸟符宁来解读实时音摄像开荒有如何坑?甚至有关环信录制客泰山压顶不弯腰的六大利用处景和十大黑科学和技术。实际情况环信简单介绍环信创设于二零一一年2月,是一家本国超过的商店级软件服务提供商,于二零一五年荣膺“Gartner 2015 Cool Vendor”。成品包涵本国上线最初规模最大的即时通讯云平台——环信即时通信云,以至移动端最棒执行的全媒体智能云客服平台——环信移动客服。报名方法点此链接步向报名:

图片 1

四 代码示例

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    //环信相关集成
    //AppKey:注册的AppKey,详细见下面注释。
    //apnsCertName:推送证书名(不需要加后缀),详细见下面注释。

    EMOptions *options = [EMOptions optionsWithAppkey:@"1110170830178623#mengzhu"];
    options.apnsCertName = @"iosAppProCer";
    [[EMClient sharedClient] initializeSDKWithOptions:options];

    //EaseUI
    [[EaseSDKHelper shareHelper] hyphenateApplication:application
                        didFinishLaunchingWithOptions:launchOptions
                                               appkey:@"1110170830178623#mengzhu"
                                         apnsCertName:@"iosAppProCer"
                                          otherConfig:@{kSDKConfigEnableConsoleLogger:[NSNumber numberWithBool:YES]}];

    //环信推送
    EMPushOptions * pushOptions = [[EMClient sharedClient] pushOptions];
    //显示内容
    pushOptions.displayStyle = 1;
    //更新配置到服务器,该方法为同步方法,如果需要,请放到单独线程
    EMError *error = [[EMClient sharedClient] updatePushOptionsToServer];
    if(!error) {
        // 成功
    }else {
        // 失败
    }

    // 注册APNS离线推送  iOS8 注册APNS
    if ([application respondsToSelector:@selector(registerForRemoteNotifications)]) {
        [application registerForRemoteNotifications];
        UIUserNotificationType notificationTypes = UIUserNotificationTypeBadge |
        UIUserNotificationTypeSound |
        UIUserNotificationTypeAlert;
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:notificationTypes categories:nil];
        [application registerUserNotificationSettings:settings];
    }
    else{
        UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeBadge |
        UIRemoteNotificationTypeSound |
        UIRemoteNotificationTypeAlert;
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:notificationTypes];
    }

    // 设置应用程序的图标右上角的数字
    [application setApplicationIconBadgeNumber:0];

    //环信添加监听在线推送消息
    [[EMClient sharedClient].chatManager addDelegate:self delegateQueue:nil];
    return YES;
}

// APP进入后台
- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [[EMClient sharedClient] applicationDidEnterBackground:application];
}

// APP将要从后台返回
- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [[EMClient sharedClient] applicationWillEnterForeground:application];
}

// 当掉线时,iOS SDK 会自动重连,只需要监听重连相关的回调,无需进行任何操作。
- (void)connectionStateDidChange:(EMConnectionState)aConnectionState
{
}
//注册环信
EMError *error = [[EMClient sharedClient] registerWithUsername:@"8001" password:@"111111"];
if (error==nil) {
    NSLog(@"注册成功");
}

//登录环信 登录一次就可以设置 自动登录了 所以要先判断一次
BOOL isAutoLogin = [EMClient sharedClient].options.isAutoLogin;
if (!isAutoLogin) {
    EMError *error = [[EMClient sharedClient] loginWithUsername:@"11236655" password:@"112233"];
          if (!error) {
               [[EMClient sharedClient].options setIsAutoLogin:YES];
              }
  }

//退出环信
EMError *error = [[EMClient sharedClient] logout:YES];
if (!error) {
    NSLog(@"环信退出成功");
 }

//环信相关  其他设备登录
- (void)userAccountDidLoginFromOtherDevice{}

//创建聊天 可以直接使用或者继承于EaseMessageViewController
//环信ID:@"8001"
//聊天类型:EMConversationTypeChat
EaseMessageViewController *chatController = [[EaseMessageViewController alloc] initWithConversationChatter:@"8001" conversationType:EMConversationTypeChat];

//环信消息推送处理
//注册和上传devicetoken
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
    //环信注册通知
    [[EMClient sharedClient] bindDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
    NSString *str = [NSString stringWithFormat: @"Error: %@",err];
    MZLog(@"%@",str);
}

//监听环信在线推送消息
- (void)messagesDidReceive:(NSArray *)aMessages{

    if (aMessages.count == 0) {
        return;
    }

    for (EMMessage * message in aMessages) {
        UIApplicationState state = [[UIApplication sharedApplication] applicationState];
        switch (state) {
                //前台运行
            case UIApplicationStateActive:
                [self showPushNotificationMessage:message];
                break;
                //待激活状态
            case UIApplicationStateInactive:
                [self showPushNotificationMessage:message];

                break;
                //后台运行
            case UIApplicationStateBackground:
                [self showPushNotificationMessage:message];
                break;


            default:
                break;
        }
    }

}

//监听环信之后  发送本地通知
- (void)showPushNotificationMessage:(EMMessage *)message{
    EMPushOptions *options = [[EMClient sharedClient] pushOptions];
    options.displayStyle = 1;
    [[UIApplication sharedApplication] cancelAllLocalNotifications];
    UILocalNotification *notification = [[UILocalNotification alloc] init];
    notification.fireDate = [NSDate date]; //触发通知的时间
    if (options.displayStyle == 1) {
        EMMessageBody *messageBody = message.body;
        NSString *messageStr = nil;
        switch (messageBody.type) {
            case 1:{
                messageStr = ((EMTextMessageBody *)messageBody).text;
            }
                break;
            case 2:{
                messageStr = @"发来一张图片";
            }
                break;
            case 4:{
                messageStr = @"发来ta的位置";
            }
                break;
            case 5:{
                messageStr = @"发来一段语音";
            }
                break;
            default:
                break;
        }

        notification.alertBody = [NSString stringWithFormat:@"%@",messageStr];
        notification.userInfo = @{@"msgtype":@(1),@"mid":message.messageId,@"f":message.from};
        notification.alertAction = NSLocalizedString(@"open", @"Open");
        notification.timeZone = [NSTimeZone defaultTimeZone];
        notification.repeatInterval = 0;
        notification.soundName= UILocalNotificationDefaultSoundName;
        //发送通知
        [[UIApplication sharedApplication] scheduleLocalNotification:notification];

        UIApplication *application = [UIApplication sharedApplication];
        application.applicationIconBadgeNumber += 1;
    }
}

//本地通知点击事件
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
    // 必须要监听--应用程序在后台的时候进行的跳转
    if (application.applicationState == UIApplicationStateInactive) {
        [self messageClickHandleWith:notification];
    }
}

//私信消息退推送点击事件
- (void)messageClickHandleWith:(UILocalNotification *)notification
{
    NSDictionary * dic = [notification userInfo];
    UIViewController * controller = [self getCurrentVC];
    MZOtherUserInfoModel * model = [MZOtherUserInfoModel new];
    model.uid = dic[@"mid"];
    model.nickname = dic[@"f"];
    MZMessageChatViewController * chat = [[MZMessageChatViewController alloc]initWithUserModel:model];
    [controller.navigationController pushViewController:chat animated:YES];
}

//获取当前controller
- (UIViewController *)getCurrentVC
{
    UIViewController *result = nil;
    UIWindow * window = [[UIApplication sharedApplication] keyWindow];
    //app默认windowLevel是UIWindowLevelNormal,如果不是,找到UIWindowLevelNormal的
    if (window.windowLevel != UIWindowLevelNormal)
    {
        NSArray *windows = [[UIApplication sharedApplication] windows];
        for(UIWindow * tmpWin in windows)
        {
            if (tmpWin.windowLevel == UIWindowLevelNormal)
            {
                window = tmpWin;
                break;
            }
        }
    }
    id  nextResponder = nil;
    UIViewController *appRootVC=window.rootViewController;
    //    如果是present上来的appRootVC.presentedViewController 不为nil
    if (appRootVC.presentedViewController) {
        nextResponder = appRootVC.presentedViewController;
    }else{

        UIView *frontView = [[window subviews] objectAtIndex:0];
        nextResponder = [frontView nextResponder];
    }

    if ([nextResponder isKindOfClass:[UITabBarController class]]){
        UITabBarController * tabbar = (UITabBarController *)nextResponder;
        UINavigationController * nav = (UINavigationController *)tabbar.viewControllers[tabbar.selectedIndex];
        //        UINavigationController * nav = tabbar.selectedViewController ; 上下两种写法都行
        result=nav.childViewControllers.lastObject;

    }else if ([nextResponder isKindOfClass:[UINavigationController class]]){
        UIViewController * nav = (UIViewController *)nextResponder;
        result = nav.childViewControllers.lastObject;
    }else{
        result = nextResponder;
    }
    return result;
}

//远程消息推送点击处理
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    if(userInfo)
    {
      //
    }
}

有时先 粗略记载 后续不常间会细化:State of Qatar

环信创立于二零一二年1五月,是一家本国当先的公司级软件服务提供商,于贰零壹肆年荣膺“Gartner 二零一六 Cool Vendor”。产物包含国内上线最先规模最大的即时通信云平台——环信即时通信云,以致移动端最棒实行的全媒体智能云客服平台——环信移动客泰山压顶不弯腰。

三 相关配置

成立上传证书用于新闻推送

授课嘉宾:环信姿容担任小双mm

二 sdk集成

//集成环信SDK
pod 'Hyphenate',
//集成环信EaseUI
pod 'EaseUI', :git => 'https://github.com/easemob/easeui-ios-hyphenate-cocoapods.git', :tag => '3.3.2'
注意: 由于SDK改成了动态库,EaseUI引入的头文件Full版本和Lite版本不同,导致集成EaseUI失败。代码中包含了宏ENABLE_LITE的定义这个是为了区分集成Lite版本SDK还是Full版本SDK,当通过pod在集成EaseUILite时会在Build Settings> GCC_PREPROCESSOR_DEFINITIONS >ENABLE_LITE=1中定义ENABLE_LITE,集成EaseUI时则不会定义,所以开发者不需要关注这个字段,如果集成Lite版本SDK,建议使用
//集成环信Lite版SDK
pod 'HyphenateLite',
//集成环信EaseUI
pod 'EaseUILite', :git =>'https://github.com/easemob/easeui-ios-hyphenate-cocoapods.git', :tag => '3.3.2'

*总之 真的是会遇到很多坑 各种冲突什么的 EaseUI中含有第三方(MBProgressHUD、MJRefresh、MWPhotoBrowser、SDWebImage) 需要大家注意 我最后是物理集成EaseUI :( 其实我更喜欢pod

☞ 在线问答

意气风发 环信简单介绍

创立于二〇一二年八月,是一家境内超越的铺面级软件服务提供商,于二〇一四年荣获“Gartner 二零一六 Cool Vendor”。成品富含国内上线最先规模最大的即时通信云平台——环信即时通信云,以致移动端最好试行的全媒体智能云客服平台——环信客户相互影响云。
有关链接

小双mm

图片 2

办法②:直接抬高Wechat号:huanxin-hh

图片 3

郑重声明:本文版权归新匍京a奥门-最全网站手机版app官方下载所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。