Platform

Platform

  • Getting Started
  • API

›IOS SDK

Getting Started

  • Create Your App

Quick Starts

  • 555 Samples

Mobile SDK (v1.0)

  • Overview
  • IOS SDK

    • Getting started
    • Installation Guide
    • How to do user authentication
    • How to subscribe for notifications
    • How to initiate or accept PSTN call
    • How to initiate or accept video call
    • How to set log level for SDK
    • Release Notes

    Android SDK

    • Getting started
    • Installation Guide
    • How to do user authentication
    • How to subscribe for notifications
    • How to initiate or accept PSTN call
    • How to initiate or accept video call
    • How to set log level for SDK
    • Release Notes

Mobile SDK (v2.0)

  • Overview
  • IOS SDK

    • Getting started
    • Installation Guide
    • How to do user authentication
    • How to subscribe for notifications
    • How to initiate or accept PSTN call
    • How to initiate or accept VIDEO call
    • How to initiate or join ANONYMOUS VIDEO call
    • Release Notes
    • Reference code - How to initiate or accept PSTN Call
    • Reference code - How to initiate or accept Video Call
    • Reference code - How to initiate or join Anonymous Video Call

    Android SDK

    • Getting started
    • Installation Guide
    • How to do user authentication
    • How to subscribe for notifications
    • How to initiate or accept PSTN call
    • How to intiate or accept Video Call
    • How to intiate or accept ANONYMOUS VIDEO Call
    • Release Notes
    • Reference code - How to initiate or accept PSTN Call
    • Reference code - How to initiate or accept Video Call
    • Reference code - How to initiate or join Anonymous Video Call

    React Native SDK

    • Getting started
    • Installation Guide
    • How to do user authentication
    • How to subscribe for notifications
    • How to initiate or accept PSTN call
    • Release Notes

WebRTC JS SDK

  • Overview
  • Getting Started
  • How to do user authentication
  • How to subscribe for notifications
  • How to initialize SDK
  • How to initiate or accept PSTN call
  • How to initiate or accept video call
  • How to create a screen share session
  • Release Notes

Reference code snippet - How to initiate or accept Video Call

Sample Video call implementation.

//AppDelegate.swift
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        //SDK Initialization
        Rtc555Sdk.initializeLibrary()
        
        return true
    }
}
//DashboardViewController.swift
class DashboardViewController {
    //After successful login

    func configureSDK {
        //SDK Config should be called before accessing other SDK APIs 
        let config:Rtc555Config = Rtc555Sdk.sharedInstance.getConfig()
        config.routingId = "a2685b26-5ef0-11ea-83a9-fa163e547f24@uc-prod.comcast.com"  // Unique id for the user logged in 555 platform. (Identity manager response) 
        config.url = "https://evm.iris.comcast.net" // Event manager URL
        config.token = "<555 JWT token>" // JWT token for accessing the 555 SDK/backend APIs. Token can be access from the 555 login response. 
        config.domain = "uciris12.comcast.net" // Unique domain name 
        config.notificationManagerUrl =  "https://ntm.iris.comcast.net/" //(Optional) For mobile notifications from 555 Platform
        config.isAnonymous = false // Set it to true for anonymous video call.

        Rtc555Sdk.setConfig(config: config)
    }
}
//VideoCallViewController.swift
class VideoCallViewController {

    private var localStreamId: String!
    private var remoteStreamId: String!

    private var localRenderer : RtcRenderer!
    private var remoteRenderer : RtcRenderer?

    override func viewDidLoad() {
        super.viewDidLoad()
        setupRenderers()
    }
    private func setupRenderers(){
        self.localRenderer =  createRenderer(self.localView.bounds)
        self.remoteRenderer = createRenderer(self.remoteView.bounds)
    }
    
    private func createRenderer(_ size: CGRect) -> RtcRenderer {
        return  RtcRenderer(frameSize: size)!
    }

    func createLocalPreview() {
        //Create local preview
        Rtc555Video.createStream(callType: "outgoing", rtcVideoDelegate: self) //Wait for "onLocalStream" callback
    }

    func initiateVideoCall {
        //SDK Video Call
        Rtc555Video.call(targetEmailID: "user1@comcast.com", notificationPayload: buildVideoNotificationPayload(), streamId: self.localStreamId, rtcVideoDelegate: self) { result in
            switch(result){
            case .success(let callId):
                Log.d("Call Success and callid is = \(callId)") //Wait for "onRemoteStream" callback
            case .failure(let error):
                print(error)
            }
        }
    }

    //build notification  payload   
    private func buildVideoNotificationPayload() -> [AnyHashable : Any] {
        
        let data:[String: Any] = ["cname" : "Caller Name",
                                  "cid" : "user1",
                                  "isVideoOnly" : true]
        let notification = ["type" : "video",
                               "topic": "federation/video"]
        
        let userData = ["data": data, "notification" : notification]
        
        return userData
    }
}
extension VideoCallViewController: Rtc555SdkDelegate {
    
    //SDK onNotification callback
    func onNotification(notification notificationData: [AnyHashable : Any]) {
        
        let pushType = NotificationType(rawValue: ((notificationData["type"] as? String) ?? ""))!
        switch(pushType){
        case .notify:
            print("xmpp notify")

            //After user accepts incoming video call invite, call SDK accept API with received payload
            self.acceptVideoCall(userInfo:notificationData)
        case .cancel:
            print("xmpp cancel")

        case .chat:
            print("xmpp chat")
            
        default:
            print(" Failed to determine notification type")
        }
        }
    }

    func acceptVideoCall(userInfo:[AnyHashable : Any]) {

        //Create local stream with callType as "incoming"
        //Get local stream Id from "onLocalStream" callback then call accept video call API

        //SDK accept
        Rtc555Video.accept((notificationData: buildNotificationData(userInfo:userInfo), streamId: localStreamId, rtcVoiceDelegate: self) { result in
            switch result {
            case .success(let callId):
                print("Call Success and callid is = \(callId)") //Wait for "onRemoteStream" callback
            case .failure(let error):
                print(error)
            }
        }
    }

    private func buildNotificationData(userInfo:[AnyHashable : Any]) -> Dictionary {
        let notificationdata = ["trace_id" : (userInfo["trace_id"] as? String) ?? "",
                            "room_id" : (userInfo["room_id"] as? String) ?? "",
                            "rtc_server" : n(userInfo["rtc_server"] as? String) ?? "",
                            "to_routing_id" : (userInfo["routing_id"] as? String) ?? "",
                            "room_token" : (userInfo["room_token"] as? String) ?? "",
                            "room_token_expiry_time" : (userInfo["room_token_expiry_time"] as? Int64) ?? 0
        ] as [String : Any]       
        return notificationdata
    }

extension VideoCallViewController: Rtc555VideoDelegate {
    
    func onLocalStream(streamId mediastreamId: String) {
        self.localStreamId = mediastreamId
        self.localRenderer.addStream(streamId: mediastreamId)

        //Initiate actual video call
        self.initiateVideoCall()
    }

    func onRemoteStream(streamId mediastreamId: String) {
        self.remoteStreamId = mediastreamId
        self.remoteRenderer?.addStream(streamId: mediastreamId)
    }
}

extension VideoCallViewController: Rtc555VoiceDelegate {
    
    //SDK voice callbacks
    func onStatus(status callStatus: CallStatus, id callId: String) {
        switch (callStatus){
        
        case .initializing:
            //Initializing

        case .connecting:
             //Connecting

        case .connected:
            //Call connected

        case .reconnecting:
            //Reconnecting
            
        case .disconnected:
            //Call ended
            
        case .hold:
            //Call is on hold
        }
    }
        
    func onError(error errorInfo: Error, id callId: String) {
        print("Error: \(String(describing: errorInfo)) for callId \(callId)")
    }
}

//VideoCallViewController.swift
class VideoCallViewController {
    // User tapped on mute audio button
    @IBAction func buttonMuteAudio(_ sender: Any) {

        //SDK mute audio only
        Rtc555Video.audioMuteToggle(callId: currentCallId)
    }
}
//VideoCallViewController.swift
class VideoCallViewController {
    // User tapped on unmute call button
    @IBAction func buttonMuteVideo(_ sender: Any) {

        //SDK mute video only
        Rtc555Video.videoMuteToggle(callId: currentCallId)
    }
}
//VideoCallViewController.swift
class VideoCallViewController {
    // User tapped flip camera button
    @IBAction func buttonFlipCamera(_ sender: Any) {

        //SDK flip camera
        Rtc555Video.flipCamera()
    }
}
//VideoCallViewController.swift
class VideoCallViewController {
   // User tapped on end call button
   @IBAction func buttonEndCall(_ sender: Any) {

       //SDK end call
       Rtc555Video.hangup(callId: currentCallId)
   }
}
//AppDelegate.swift
class AppDelegate: UIResponder, UIApplicationDelegate {

    func applicationDidEnterBackground(_ application: UIApplication) {
        //If no active calls
        if !hasActiveCall {

            //SDK cleanup
            Rtc555Sdk.cleanup()
        }
    }
}
← Reference code - How to initiate or accept PSTN CallReference code - How to initiate or join Anonymous Video Call →
Docs
Getting StartedGuidesAPI Reference
More
BlogGitHub
555 Platform
Copyright © 2024 555 Platform ™
555docs-v0.0.94