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
  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: "") { (validationState) in
//                Session registration completion block                
                guard let `self` = self else {
                DispatchQueue.main.async {
                    switch validationState {
                    case .success:
                        // Session validation successfully done and session has been registered.
                    case .failure(let error):
                        // Error while registering the session. Please verify the session ID and App 		                token.

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: "", 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 {
                screenShareObj?.addImage(buffer: sampleBuffer)
                // To handle video buffer sample
            case RPSampleBufferType.audioApp:
                // To handle audio buffer sample for application audio
            case RPSampleBufferType.audioMic:
                // To handle audio buffer sample for mic audio