Building the App

Carry out the below steps to build your application by referring to the examples in the right panel.

  1. Import the AssistSDK module into your project.
  2. Generate an SDK token from https://assist.zoho.com/app/settings/integrations/sdk
  3. Initiate a session to generate a session ID. 
  4. Validate and register the SDK token and session ID by using API AssistSession.register.
  5. Create an object "AssistSession" in the RPBroadcastSampleHandler class.
  6. Feed the video samples to the AssistSession object.

 

AssistSession Class

CopiedImport 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
                 }
           }
  }

To validate token and session ID using the below API in your main app.

RPBroadcastSampleHandler Class

CopiedImport 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

Copiedoverride 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
        }
  }