Building the App
Carry out the below steps to build your application by referring to the examples in the right panel.
- Import the AssistSDK module into your project.
- Generate an SDK token from https://assist.zoho.com/app/settings/integrations/sdk
- Initiate a session to generate a session ID.
- Validate and register the SDK token and session ID by using API AssistSession.register.
- Create an object "AssistSession" in the RPBroadcastSampleHandler class.
- Feed the video samples to the AssistSession object.
AssistSession Class
To validate token and session ID using the below API in your main app.
Import AssistSDK
AssistSession.register(session: id, token: token, appGroup: "group.com.example.appgroup") { (validationState) in
// Session registration completion block
guard let `self` = self else {
return
}
DispatchQueue.main.async {
switch validationState {
case .success:
// Session validation successfully done and session has been registered.
break
case .failure(let error):
// Error while registering the session. Please verify the session ID and App token.
break
}
}
}
RPBroadcastSampleHandler Class
Import AssistSDK
class SampleHandler: RPBroadcastSampleHandler, AssistSessionCallBack {
var screenShareObj:AssistSession?
override func broadcastStarted(withSetupInfo setupInfo: [String : NSObject]?)
{
guard let screenShare = AssistSession(delegate: self, appGroup: "group.com.example.appgroup", image: .best) else {
// WARNING: These are the possible reasons for this block of code execution.
// Reason 1: You can initiate one AssistSession object for a session. If youcreate another, the AssistSession object will return null.
// Reason 2: The session data may not be registered.
fatalError("Session duplication or Invalid session data")
}
// Session created successfully
self.screenShareObj = screenShare
// To initiate the settings network connection
screenShareObj?.isNetworkAvailable = true
}
}
Video Samples
override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {
switch sampleBufferType {
case RPSampleBufferType.video:
screenShareObj?.addImage(buffer: sampleBuffer)
// To handle video buffer sample
case RPSampleBufferType.audioApp:
// To handle audio buffer sample for application audio
break
case RPSampleBufferType.audioMic:
// To handle audio buffer sample for mic audio
break
}
}