美文网首页
AIHelp~5.1.1简单接入

AIHelp~5.1.1简单接入

作者: 小小鸟他大爷 | 来源:发表于2024-07-30 14:51 被阅读0次

    pod导入

    target 'AIHelpSDK' do

      # Comment the next line if you don't want to use dynamic frameworks

      use_frameworks!

      pod'AIHelpSDK'

      # Pods for AIHelpSDK

    end



    引入系统库


    引入AIhelp文件

    #import <AIHelpSupportSDK/AIHelpSDKConfig.h>

    #import <AIHelpSupportSDK/AIHelpSupportSDK.h>

    初始化

    注册初始化监听

       [AIHelpSupportSDK registerAsyncListener:listener eventType:AIHelpEventInitialization];

    拉起客服

     AIHelpApiConfigBuilder *builder = [[AIHelpApiConfigBuilder alloc] init];

        builder.entranceId=@"E001";

    //    builder.welcomeMessage = message;

        [AIHelpSupportSDK showWithApiConfig:builder.build];

    未读消息监听

    [AIHelpSupportSDK fetchUnreadMessageCount];

        [AIHelpSupportSDK registerAsyncListener:listener eventType:AIHelpEventMessageArrival];

    监听方法,根据AIHelp反回的eventType类型判断是初始化还是未读消息数量

    voidlistener(constchar*eventData,void(*acknowledge)(constchar*ackData)) {

        // 将char类型转换为NSString

        NSString*nsString = [[NSStringalloc]initWithBytes:eventDatalength:strlen(eventData)encoding:NSUTF8StringEncoding];

        NSDictionary*dict = [ViewControllerjsonStrtodictWithStr:nsString];

        NSLog(@"dict==aihelp==%@",dict);

        inteventType = [[dictobjectForKey:@"eventType"]intValue];

        if(eventType ==0) {

            BOOLisSuccess = [[dictobjectForKey:@"isSuccess"]boolValue];

            if(isSuccess) {

                isInit=YES;

            }else

            {

                isInit=NO;

            }

        }elseif(eventType ==5)

        {

            NSLog(@"messageCount==未读消息数量=%@",[dict objectForKey:@"msgCount"]);

        }

    }

    相关文章

      网友评论

          本文标题:AIHelp~5.1.1简单接入

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