iOS SDK
本文为您介绍iOS系统集成SDK的方法。
前提条件
已开通音视频通信服务。具体操作,请参见开通服务。
环境要求
iPhone:支持iPhone 5及之后的设备。
CPU架构:支持实体设备架构arm64,不支持模拟器i386、x86架构。
系统版本:支持iOS 8.0及以上版本。
Xcode:支持Xcode 11.1版本,更多信息,请参见Xcode。
其他:不支持bitcode,不支持屏幕旋转。
步骤一:设备端集成SDK
下载并解压iOS SDK,解压文件如下。
打开Xcode工具,新建工程,将解压后的两个库文件逐个加载到工程中。
步骤二:实现通信功能
初始化SDK。
[[IotRtc shareInstance] rtcInit:self.productKeyInput.text deviceName:self.deviceNameInput.text deviceSecret:self.deviceSecretInput.text hostUrl:self.mqttHostInput.text port:443 instance:self.engine];
注册信令回调函数。
[[IotRtc shareInstance] setInvitationArrivalCallback:demo_invitation_arrival_handler]; [[IotRtc shareInstance] setRequestGrantedCallback:demo_request_granted_handler]; [[IotRtc shareInstance] setGuestReplyCallback:demo_guest_reply_handler]; [[IotRtc shareInstance] setConnectStatusCallback:demo_connection_status_handler];
各个回调函数的具体实现,请参见iOS Demo。回调函数的详细说明,请参见回调及监听。相关接口的详细说明,请参见基础接口。
主叫方发起通话。
ChannelInfo *ch = [[ChannelInfo alloc] init]; [ch initWithPkDn:(NSString*)_peerProductKeyInput.text deviceName:(NSString*)_peerDeviceNameInput.text]; [[IotRtc shareInstance] launchChannel:ch];
主叫方结束通话。
[[IotRtc shareInstance] cancelChannel:channelId];
被呼叫方接听通话。
[[IotRtc shareInstance] guestResponse:GUEST_ACCEPT channelId:channelId];
被呼叫方结束通话。
[[IotRtc shareInstance] guestLeaveChannel:channelId];
退出音视频通信服务。
[[IotRtc shareInstance] rtcDeinit];
步骤三:通信监测
在音视频通信增值服务的服务详情页面,查看通信监测信息,例如通话总时长、通话产生的时间等。