### Run Pod Install Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/AuviousGoogleWebRTC/README.md After configuring your Podfile, run this command in your project directory to install the SDK. ```bash $ pod install ``` -------------------------------- ### Install AuviousSDK from GitHub Repo Source: https://github.com/auvious/auvious-sdk-ios/blob/master/README.md Install the AuviousSDK directly from its GitHub repository using a specific tag. ```ruby pod 'AuviousSDK', :git => 'https://github.com/auvious/auvious-sdk-ios.git', :tag => '1.4.0' ``` -------------------------------- ### Example Push Auvious SDK to Pod Source: https://github.com/auvious/auvious-sdk-ios/blob/master/README.md An example of how to push the Auvious SDK to the CocoaPods repository using a specific pod name. ```bash pod repo push auvious-cocoa-pod AuviousSDK.podspec --verbose --allow-warnings ``` -------------------------------- ### Example Add Auvious Podspec Repo Source: https://github.com/auvious/auvious-sdk-ios/blob/master/README.md An example of adding the Auvious CocoaPods repository with a specific pod name. ```bash pod repo add auvious-cocoa-pod git@github.com:auvious/CocoaPodSpecs.git ``` -------------------------------- ### Install AuviousSDK via CocoaPods Source: https://context7.com/auvious/auvious-sdk-ios/llms.txt Add the AuviousSDK to your project's Podfile and specify the source repository. Run 'pod install' to integrate the SDK. ```ruby source 'https://github.com/auvious/CocoaPodSpecs.git' source 'https://cdn.cocoapods.org/' target 'MyApp' do pod 'AuviousSDK', '1.4.0' end ``` ```bash pod install ``` -------------------------------- ### Install CocoaMQTT with CocoaPods Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/CocoaMQTTWebsocket_IOS13/README.md Integrate CocoaMQTT into your Xcode project by adding 'pod \'CocoaMQTT\'' to your Podfile and running 'pod install'. Remember to import the library afterwards. ```ruby use_frameworks! target 'Example' do pod 'CocoaMQTT' end ``` -------------------------------- ### Setup and Login with AuviousConferenceSDK Source: https://github.com/auvious/auvious-sdk-ios/blob/master/README.md Initializes the SDK delegate, configures connection parameters, and logs in to the Auvious platform. Ensure you replace placeholder values like '', '', and '' with your actual credentials. ```swift import AuviousSDK class ConferenceManager: AuviousSDKConferenceDelegate { func setup() { AuviousConferenceSDK.sharedInstance.delegate = self // Configure the SDK AuviousConferenceSDK.sharedInstance.configure( params: [:], username: "", password: "", name: nil, clientId: "", baseEndpoint: "https://auvious.video/", mqttEndpoint: "auvious.video" ) // Log in AuviousConferenceSDK.sharedInstance.login( onLoginSuccess: { [weak self] endpoint in self?.joinConference() }, onLoginFailure: { error in print("Login failed: \(error)") } ) } func joinConference() { AuviousConferenceSDK.sharedInstance.joinConference( conferenceId: "", onSuccess: { [weak self] conference in // Start publishing local audio/video self?.publishLocalStream() }, onFailure: { error in print("Failed to join: \(error)") } ) } func publishLocalStream() { AuviousConferenceSDK.sharedInstance.startPublishLocalStreamFlow(type: .micAndCam) } func leaveConference() { AuviousConferenceSDK.sharedInstance.leaveConference( conferenceId: "", onSuccess: { }, onFailure: { _ in } ) } // MARK: - AuviousSDKConferenceDelegate func auviousSDK(didReceiveLocalVideoTrack localVideoTrack: RTCVideoTrack!) { // Render the local video track in your UI } func auviousSDK(didReceiveRemoteStream stream: RTCMediaStream, streamId: String, endpointId: String, type: StreamType) { // Render the incoming remote stream in your UI } func auviousSDK(didReceiveLocalStream stream: RTCMediaStream, streamId: String, type: StreamType) { // Local stream is ready } func auviousSDK(onError error: AuviousSDKError) { print("SDK error: \(error)") } func auviousSDK(didChangeState newState: StreamEventState, streamId: String, streamType: StreamType, endpointId: String) { // React to stream state transitions (connecting, connected, disconnected, etc.) } func auviousSDK(trackMuted type: StreamType, endpointId: String) { } func auviousSDK(trackUnmuted type: StreamType, endpointId: String) { } func auviousSDK(conferenceOnHold flag: Bool) { } func auviousSDK(didReceiveConferenceEvent event: ConferenceEvent) { } func auviousSDK(didRejoinConference conference: ConferenceSimpleView) { } func auviousSDK(recorderStateChanged toActive: Bool) { } func auviousSDK(agentPortraitMode flag: Bool, endpointId: String) { } func auviousSDK(screenSharingStarted: Bool) { } func auviousSDK(screenSharingStopped: Bool) { } func auviousSDK(didResumeFromBackground withActiveAudio: Bool) { } } ``` -------------------------------- ### Start and Stop Screen Sharing with ReplayKit Source: https://context7.com/auvious/auvious-sdk-ios/llms.txt Request ReplayKit permission before starting the screen share. The SDK provides delegate callbacks for status updates. Ensure proper error handling for publish and unpublish operations. ```swift // Step 1: Request permission (may show iOS system dialog) AuviousConferenceSDK.sharedInstance.requestScreenSharePermission { [weak self] granted in guard granted else { return } DispatchQueue.main.async { do { self?.screenStreamId = try AuviousConferenceSDK.sharedInstance .startPublishLocalStreamFlow(type: .screen) } catch { print("Screen share publish failed: \(error)") } } } // Step 2: SDK fires delegate callbacks func auviousSDK(screenSharingStarted: Bool) { /* update UI */ } func auviousSDK(screenSharingStopped: Bool) { /* update UI */ } // Step 3: Stop sharing do { try AuviousConferenceSDK.sharedInstance .startUnpublishLocalStreamFlow(streamId: screenStreamId, streamType: .screen) } catch { print("Stop share error: \(error)") } ``` -------------------------------- ### Install AuviousSDK Pod Source: https://github.com/auvious/auvious-sdk-ios/blob/master/README.md Add the AuviousSDK pod with a specific version to your target dependencies in the Podfile. ```ruby pod 'AuviousSDK', '1.4.0' ``` -------------------------------- ### Connect to MQTT Broker with MQTT 5.0 Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/CocoaMQTTWebsocket_IOS13/README.md Example of creating and connecting a CocoaMQTT5 client to an MQTT broker using MQTT 5.0 protocol. Configure connection properties, username, password, will message, and keep-alive interval. ```swift ///MQTT 5.0 let clientID = "CocoaMQTT-" + String(ProcessInfo().processIdentifier) let mqtt5 = CocoaMQTT5(clientID: clientID, host: "broker.emqx.io", port: 1883) let connectProperties = MqttConnectProperties() connectProperties.topicAliasMaximum = 0 connectProperties.sessionExpiryInterval = 0 connectProperties.receiveMaximum = 100 connectProperties.maximumPacketSize = 500 mqtt5.connectProperties = connectProperties mqtt5.username = "test" mqtt5.password = "public" mqtt5.willMessage = CocoaMQTTMessage(topic: "/will", string: "dieout") mqtt5.keepAlive = 60 mqtt5.delegate = self mqtt5.connect() ``` -------------------------------- ### Install CocoaAsyncSocket with CocoaPods Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/MqttCocoaAsyncSocket_IOS13/README.markdown Add this line to your Podfile to install CocoaAsyncSocket using CocoaPods. Use `use_frameworks!` if targeting iOS 8+ or Swift. ```ruby use_frameworks! # Add this if you are targeting iOS 8+ or using Swift pod 'CocoaAsyncSocket' ``` -------------------------------- ### Connect to MQTT Broker with MQTT 3.1.1 Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/CocoaMQTTWebsocket_IOS13/README.md Example of creating and connecting a CocoaMQTT client to an MQTT broker using MQTT 3.1.1 protocol. Set username, password, will message, and keep-alive interval. ```swift ///MQTT 3.1.1 let clientID = "CocoaMQTT-" + String(ProcessInfo().processIdentifier) let mqtt = CocoaMQTT(clientID: clientID, host: "broker.emqx.io", port: 1883) mqtt.username = "test" mqtt.password = "public" mqtt.willMessage = CocoaMQTTMessage(topic: "/will", string: "dieout") mqtt.keepAlive = 60 mqtt.delegate = self mqtt.connect() ``` -------------------------------- ### Install AuviousGoogleWebRTC Pod Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/AuviousGoogleWebRTC/README.md Add this to your Podfile to integrate the WebRTC SDK into your XCode project. Ensure you specify the correct target and platform version. ```ruby source 'https://github.com/auvious/CocoaPodSpecs.git' target 'YOUR_APPLICATION_TARGET_NAME_HERE' do platform :ios, '10.0' pod 'AuviousGoogleWebRTC' end ``` -------------------------------- ### Install CocoaMQTT with Carthage Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/CocoaMQTTWebsocket_IOS13/README.md Add CocoaMQTT to your Cartfile, run 'carthage update', and then embed the generated xcframeworks into your Xcode project's target. ```bash github "emqx/CocoaMQTT" "master" ``` -------------------------------- ### Import Starscream Framework Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/Starscream_IOS13/README.md Import the Starscream framework to begin using its WebSocket functionalities. Ensure the framework is added to your project via installation instructions. ```swift import Starscream ``` -------------------------------- ### CocoaPods Integration for WebSockets Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/CocoaMQTTWebsocket_IOS13/README.md Modify your Podfile to include the CocoaMQTT/WebSockets pod for WebSocket support. Execute 'pod install' after changes. ```ruby use_frameworks! target 'Example' do pod 'CocoaMQTT/WebSockets' end ``` -------------------------------- ### AuviousConferenceSDK Stream Management Source: https://github.com/auvious/auvious-sdk-ios/blob/master/README.md This snippet covers starting the local media stream publishing and handling incoming remote streams. ```APIDOC ## startPublishLocalStreamFlow ### Description Starts publishing the local audio and video streams to the conference. ### Method `AuviousConferenceSDK.sharedInstance.startPublishLocalStreamFlow` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **type** (StreamPublishType) - Specifies the type of streams to publish (e.g., `.micAndCam`). ### Request Example ```swift AuviousConferenceSDK.sharedInstance.startPublishLocalStreamFlow(type: .micAndCam) ``` ## Delegate Methods for Stream Events ### Description These delegate methods are part of the `AuviousSDKConferenceDelegate` protocol and are called by the SDK to inform your application about various stream-related events. ### Methods - `auviousSDK(didReceiveLocalVideoTrack localVideoTrack: RTCVideoTrack!)`: Called when the local video track is available. - `auviousSDK(didReceiveRemoteStream stream: RTCMediaStream, streamId: String, endpointId: String, type: StreamType)`: Called when a remote stream is received. - `auviousSDK(didReceiveLocalStream stream: RTCMediaStream, streamId: String, type: StreamType)`: Called when the local stream is ready. - `auviousSDK(didChangeState newState: StreamEventState, streamId: String, streamType: StreamType, endpointId: String)`: Called when the state of a stream changes (e.g., connecting, connected, disconnected). ### Usage Example Implement these methods within your class conforming to `AuviousSDKConferenceDelegate` to handle incoming and outgoing media streams and their states. ``` -------------------------------- ### Setup WebSocket Secure (WSS) MQTT Client Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/CocoaMQTTWebsocket_IOS13/README.md Configure a CocoaMQTT client to connect using WebSocket Secure (WSS). This involves setting `enableSSL` to true on the WebSocket and using the correct port (typically 443). ```swift import CocoaMQTT import CocoaMQTTWebSocket import Starscream class WebSocketManager { private var mqttClient: CocoaMQTT? var message: String = "" var token: String = "" func setupMQTTClient(with token: String) { let socket = CocoaMQTTWebSocket(uri: "/mqtt") socket.enableSSL = true mqttClient = CocoaMQTT(clientID: token, host: "host", port: 443, socket: socket) mqttClient?.delegate = self } func connect() { guard let mqttClient = mqttClient else { return } mqttClient.connect() } } extension WebSocketManager: CocoaMQTTDelegate { func mqtt(_ mqtt: CocoaMQTT, didReceive trust: SecTrust, completionHandler: @escaping (Bool) -> Void) { // Implement your custom SSL validation logic here. // For example, you might want to always trust the certificate for testing purposes: completionHandler(true) } func mqtt(_ mqtt: CocoaMQTT, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust { if let serverTrust = challenge.protectionSpace.serverTrust { completionHandler(.useCredential, URLCredential(trust: serverTrust)) return } } completionHandler(.performDefaultHandling, nil) } func mqttUrlSession(_ mqtt: CocoaMQTT, didReceiveTrust trust: SecTrust, didReceiveChallenge challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { print("\(#function), \n result:- \(challenge.debugDescription)") } func mqtt(_ mqtt: CocoaMQTT, didPublishAck id: UInt16) { print("Published message with ID: \(id)") } func mqtt(_ mqtt: CocoaMQTT, didUnsubscribeTopics topics: [String]) { print("Unsubscribed from topics: \(topics)") } func mqttDidPing(_ mqtt: CocoaMQTT) { print("MQTT did ping") } func mqttDidReceivePong(_ mqtt: CocoaMQTT) { print("MQTT did receive pong") } func mqttDidDisconnect(_ mqtt: CocoaMQTT, withError err: (any Error)?) { print("Disconnected from MQTT broker with error: \(String(describing: err))") } func mqtt(_ mqtt: CocoaMQTT, didConnectAck ack: CocoaMQTTConnAck) { print("Connected to MQTT broker with acknowledgment: \(ack)") } func mqtt(_ mqtt: CocoaMQTT, didReceiveMessage message: CocoaMQTTMessage, id: UInt16) { if let messageString = message.string { DispatchQueue.main.async { self.message = messageString } print("Received message: \(messageString) on topic: \(message.topic)") } } } ``` -------------------------------- ### Add Auvious Podspec Repo Source: https://github.com/auvious/auvious-sdk-ios/blob/master/README.md Add the Auvious CocoaPods repository to your local setup. This requires SSH authentication with GitHub. ```bash pod repo add git@github.com:auvious/CocoaPodSpecs.git ``` -------------------------------- ### Join Conference and Publish Stream Source: https://context7.com/auvious/auvious-sdk-ios/llms.txt Joins a conference and automatically starts publishing the local audio and video stream upon successful connection. Ensure you are logged in before calling this function. ```swift func joinConference(id: String) { AuviousConferenceSDK.sharedInstance.joinConference( conferenceId: id, onSuccess: { [weak self] conference in guard let conf = conference else { return } print("Joined conference: \(conf.id), version: \(conf.version)") self?.publishStream() }, onFailure: { error in print("Join failed: \(error.localizedDescription)") } ) } ``` ```swift func publishStream() { do { // StreamType options: .mic | .cam | .micAndCam | .screen let streamId = try AuviousConferenceSDK.sharedInstance .startPublishLocalStreamFlow(type: .micAndCam) print("Publishing stream: \(streamId ?? \"n/a\")") } catch AuviousSDKError.notLoggedIn { print("Must log in first") } catch AuviousSDKError.endpointNotCreated { print("Endpoint not yet created") } catch { print("Publish error: \(error)") } } ``` -------------------------------- ### Start an Outgoing Call Source: https://context7.com/auvious/auvious-sdk-ios/llms.txt Initiates an outgoing call to a specified user. Handles potential 'notLoggedIn' errors and other exceptions during call initiation. ```swift func callUser(targetUserId: String) { do { let callId = try AuviousCallSDK.sharedInstance.startCallFlow( target: targetUserId, sendMode: .micAndCam, // StreamType we publish sipHeaders: ["X-Custom-Header": "value"] // optional ) print("Outgoing call ID: \(callId ?? "-")") } catch AuviousSDKError.notLoggedIn { print("Not logged in") } catch { print("Call error: \(error)") } } ``` -------------------------------- ### Configure and Login with Auvious SDK Source: https://context7.com/auvious/auvious-sdk-ios/llms.txt Initializes the SDK, sets the delegate, and configures connection parameters before logging in. Ensure you have the correct credentials and endpoints. ```swift import AuviousSDK class CallManager: AuviousSDKCallDelegate { func setup() { let sdk = AuviousCallSDK.sharedInstance sdk.delegate = self sdk.publishVideoResolution = .min sdk.configure( username: "alice", password: "secret", organization: "my-org", baseEndpoint: "https://auvious.video/", mqttEndpoint: "auvious.video" ) sdk.login(oAuth: false, onLoginSuccess: { endpointId in print("Ready to call. Endpoint: \(endpointId ?? "-")") }, onLoginFailure: { error in print("Login failed: \(error)") }) } } ``` -------------------------------- ### Initialize Sentry SDK in Swift Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/Sentry/README.md Call this as early as possible in your application's lifecycle, ideally in `applicationDidFinishLaunching`. ```swift import Sentry // .... SentrySDK.start { options in options.dsn = "___PUBLIC_DSN___" options.debug = true // Helpful to see what's going on } ``` -------------------------------- ### configure + login Source: https://context7.com/auvious/auvious-sdk-ios/llms.txt Configures the Auvious SDK with user credentials and endpoints, then logs the user in. This is a prerequisite for most other SDK operations. ```APIDOC ## configure + login ### Description Configures the Auvious SDK with user credentials and endpoints, then logs the user in. This is a prerequisite for most other SDK operations. ### Method Signature ```swift func configure( username: String, password: String, organization: String, baseEndpoint: String, mqttEndpoint: String ) func login(oAuth: Bool, onLoginSuccess: @escaping (String?) -> Void, onLoginFailure: @escaping (Error) -> Void) ``` ### Usage Example ```swift import AuviousSDK class CallManager: AuviousSDKCallDelegate { func setup() { let sdk = AuviousCallSDK.sharedInstance sdk.delegate = self sdk.publishVideoResolution = .min sdk.configure( username: "alice", password: "secret", organization: "my-org", baseEndpoint: "https://auvious.video/", mqttEndpoint: "auvious.video" ) sdk.login(oAuth: false, onLoginSuccess: { endpointId in print("Ready to call. Endpoint: \(endpointId ?? "-")") }, onLoginFailure: { error in print("Login failed: \(error)") }) } } ``` ``` -------------------------------- ### Get Raw JSON Value Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Access the raw value of the JSON object, which can be of any type. ```swift let rawValue: Any = json.rawValue ``` -------------------------------- ### Configuring and Logging into AuviousConferenceSDK Source: https://context7.com/auvious/auvious-sdk-ios/llms.txt Configure the SDK with server and user credentials, then call login to authenticate and establish an MQTT endpoint. The success closure provides the endpoint ID and an optional conference ID. ```swift import AuviousSDK class ConferenceManager: AuviousSDKConferenceDelegate { func setup() { let sdk = AuviousConferenceSDK.sharedInstance sdk.delegate = self sdk.publishVideoResolution = .mid // .min (640x480) | .mid (960x720) | .max (1920x1080) sdk.configure( params: ["grant_type": "password", "username": "my-ticket", "password": ""], username: "my-ticket", password: "", name: "Bob", // optional display name clientId: "customer", baseEndpoint: "https://auvious.video/", mqttEndpoint: "auvious.video" ) sdk.login( onLoginSuccess: { [weak self] endpointId, conferenceId in print("Logged in. Endpoint: \(endpointId ?? "-")") self?.joinConference(id: conferenceId ?? "my-room") }, onLoginFailure: { error in print("Login failed: \(error.localizedDescription)") } ) } } ``` -------------------------------- ### Get Raw JSON Object Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Access the underlying raw Swift object representation of the JSON. ```swift let rawObject: Any = json.object ``` -------------------------------- ### Get String from JSON Dictionary Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Access a string value from a JSON dictionary using its key. ```swift // Getting a string from a JSON Dictionary let name = json["name"].stringValue ``` -------------------------------- ### SwiftyJSON Initialization and Access Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Shows how to initialize SwiftyJSON with data and access nested values using a more concise syntax. It also demonstrates safe access to potentially non-existent keys. ```swift let json = try? JSON(data: dataFromNetworking) if let userName = json[0]["user"]["name"].string { //Now you got your value } ``` ```swift let json = try? JSON(data: dataFromNetworking) let result = json[999999]["wrong_key"]["wrong_name"] if let userName = result.string { //Calm down, take it easy, the ".string" property still produces the correct Optional String type with safety } else { //Print the error print(result.error) } ``` -------------------------------- ### Get Array of Strings from JSON Array Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Extract an array of strings from a nested JSON structure. ```swift // Getting an array of string from a JSON Array let arrayNames = json["users"].arrayValue.map {$0["name"].stringValue} ``` -------------------------------- ### Get Double from JSON Array Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Access a double value from a JSON array using its index. ```swift // Getting a double from a JSON Array let name = json[0].double ``` -------------------------------- ### Get String with Custom Subscript Keys Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Access a string value using a custom array of subscript keys. ```swift // With a custom way let keys:[JSONSubscriptType] = [1,"list",2,"name"] let name = json[keys].string ``` -------------------------------- ### Initialize Sentry SDK in Objective-C Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/Sentry/README.md Ensure this is called early in the application's lifecycle, typically within `applicationDidFinishLaunching`. ```objc @import Sentry; // .... [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { options.dsn = @"___PUBLIC_DSN___"; options.debug = @YES; // Helpful to see what's going on }]; ``` -------------------------------- ### AuviousConferenceSDK - configure + login Source: https://context7.com/auvious/auvious-sdk-ios/llms.txt Configure the low-level SDK with server and user credentials, then call `login` to authenticate and establish an MQTT endpoint. The success callback provides the endpoint ID and an optional conference ID. ```APIDOC ## AuviousConferenceSDK — Low-Level Conference API `AuviousConferenceSDK.sharedInstance` is the singleton for building a fully custom conference experience. It handles authentication, conference join/leave/end, local stream publishing, remote stream subscription, mute/unmute, camera switch, audio routing, screen sharing, and background/foreground transitions via delegation. ### configure + login Configure the SDK with server and user credentials, then call `login` to authenticate and create an MQTT endpoint. The success closure provides the endpoint ID and an optional conference ID returned by the server. ```swift import AuviousSDK class ConferenceManager: AuviousSDKConferenceDelegate { func setup() { let sdk = AuviousConferenceSDK.sharedInstance sdk.delegate = self sdk.publishVideoResolution = .mid // .min (640x480) | .mid (960x720) | .max (1920x1080) sdk.configure( params: ["grant_type": "password", "username": "my-ticket", "password": ""], username: "my-ticket", password: "", name: "Bob", // optional display name clientId: "customer", baseEndpoint: "https://auvious.video/", mqttEndpoint: "auvious.video" ) sdk.login( onLoginSuccess: { [weak self] endpointId, conferenceId in print("Logged in. Endpoint: \(endpointId ?? "-")") self?.joinConference(id: conferenceId ?? "my-room") }, onLoginFailure: { error in print("Login failed: \(error.localizedDescription)") } ) } } ``` ``` -------------------------------- ### Get String with Empty Subscript Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Access a string value using an empty subscript, which might be used in specific contexts. ```swift // With a hard way let name = json[].string ``` -------------------------------- ### Get String using JSON Subscript Path Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Access nested JSON elements using a path composed of indices and keys. ```swift // Getting a string using a path to the element let path: [JSONSubscriptType] = [1,"list",2,"name"] let name = json[path].string // Just the same let name = json[1]["list"][2]["name"].string // Alternatively let name = json[1,"list",2,"name"].string ``` -------------------------------- ### AuviousConferenceSDK Configuration and Login Source: https://github.com/auvious/auvious-sdk-ios/blob/master/README.md This snippet shows how to configure the SDK with authentication parameters and log in to the Auvious platform. ```APIDOC ## configure ### Description Configures the Auvious SDK with necessary authentication and connection parameters. ### Method `AuviousConferenceSDK.sharedInstance.configure` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **params** (Dictionary) - Additional parameters for configuration. - **username** (String) - Username (or ticket) for authentication. - **password** (String) - Password for authentication. - **name** (String?) - Optional name parameter. - **clientId** (String) - Client identifier. - **baseEndpoint** (String) - Base URL for the Auvious API. - **mqttEndpoint** (String) - Hostname for the MQTT WebSocket broker. ### Request Example ```swift AuviousConferenceSDK.sharedInstance.configure( params: [:], username: "", password: "", name: nil, clientId: "", baseEndpoint: "https://auvious.video/", mqttEndpoint: "auvious.video" ) ``` ## login ### Description Logs in to the Auvious platform. Requires successful configuration. ### Method `AuviousConferenceSDK.sharedInstance.login` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **onLoginSuccess** (Callback function) - Executed upon successful login, providing the endpoint. - **onLoginFailure** (Callback function) - Executed upon login failure, providing an error object. ### Request Example ```swift AuviousConferenceSDK.sharedInstance.login( onLoginSuccess: { endpoint in // Handle successful login }, onLoginFailure: { error in print("Login failed: \(error)") } ) ``` ``` -------------------------------- ### Add Starscream as CocoaPods Dependency Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/Starscream_IOS13/README.md Include Starscream in your project by adding the specified pod to your 'Podfile'. Ensure you run 'pod install' afterwards. ```ruby source 'https://github.com/CocoaPods/Specs.git' platform :ios, '12.0' use_frameworks! pod 'Starscream', '~> 4.0.6' ``` -------------------------------- ### Create MQTT 5.0 Instance over WebSocket Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/CocoaMQTTWebsocket_IOS13/README.md Instantiate CocoaMQTT5 with a CocoaMQTTWebSocket socket for MQTT 5.0 connections. Configure connection properties like topic alias maximum. ```swift ///MQTT 5.0 let websocket = CocoaMQTTWebSocket(uri: "/mqtt") let mqtt5 = CocoaMQTT5(clientID: clientID, host: host, port: 8083, socket: websocket) let connectProperties = MqttConnectProperties() connectProperties.topicAliasMaximum = 0 // ... mqtt5.connectProperties = connectProperties // ... _ = mqtt5.connect() ``` -------------------------------- ### Import CocoaMQTT and WebSocket Libraries Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/CocoaMQTTWebsocket_IOS13/README.md Import necessary frameworks when using CocoaMQTT with WebSockets. Ensure both CocoaMQTT and Starscream are available. ```swift import CocoaMQTT import CocoaMQTTWebSocket import Starscream ``` -------------------------------- ### Add Starscream as Carthage Dependency Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/Starscream_IOS13/README.md Specify Starscream in your `Cartfile` to integrate it into your Xcode project using Carthage. Ensure you have Carthage installed via Homebrew. ```bash github "daltoniam/Starscream" >= 4.0.6 ``` -------------------------------- ### Add CocoaAsyncSocket with Carthage Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/MqttCocoaAsyncSocket_IOS13/README.markdown Include this line in your Cartfile to make CocoaAsyncSocket compatible with Carthage. The resultant frameworks will be stored in Carthage/Build. ```bash github "robbiehanson/CocoaAsyncSocket" "master" ``` -------------------------------- ### Connect to WebSocket Server Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/Starscream_IOS13/README.md Establish a connection to a WebSocket server. It is recommended to store the socket as a property to prevent deallocation. Configure connection timeout and set the delegate for event handling. ```swift var request = URLRequest(url: URL(string: "http://localhost:8080")!) request.timeoutInterval = 5 socket = WebSocket(request: request) socket.delegate = self socket.connect() ``` -------------------------------- ### Initialize JSON from Data Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Initialize a JSON object from networking data. Use `try?` for safe unwrapping. ```swift let json = try? JSON(data: dataFromNetworking) ``` -------------------------------- ### Info.plist Camera and Microphone Permissions Source: https://github.com/auvious/auvious-sdk-ios/blob/master/README.md Add these keys to your Info.plist to request camera and microphone access for video and audio calls. ```xml NSCameraUsageDescription Camera access is required for video calls. NSMicrophoneUsageDescription Microphone access is required for audio calls. ``` -------------------------------- ### Configure Info.plist for AuviousSDK Source: https://context7.com/auvious/auvious-sdk-ios/llms.txt Add necessary privacy descriptions for camera and microphone access. Optionally, enable background audio mode. ```xml NSCameraUsageDescription Camera access is required for video calls. NSMicrophoneUsageDescription Microphone access is required for audio calls. UIBackgroundModes audio ``` -------------------------------- ### startPublishLocalStreamFlow Source: https://context7.com/auvious/auvious-sdk-ios/llms.txt Begins publishing the local camera and/or microphone stream. This function returns a stream ID that uniquely identifies the publication. It may throw an `AuviousSDKError` if preconditions like being logged in or having an endpoint are not met. ```APIDOC ## startPublishLocalStreamFlow ### Description Begin publishing the local camera/microphone stream. Returns the stream ID that identifies this publication. Throws `AuviousSDKError` synchronously if preconditions fail (not logged in, no endpoint). ### Method Signature `func startPublishLocalStreamFlow(type: StreamType) throws -> String?` ### Parameters - **type** (StreamType) - Specifies the type of stream to publish. Options include `.mic`, `.cam`, `.micAndCam`, `.screen`. ### Throws - `AuviousSDKError.notLoggedIn`: If the user is not logged in. - `AuviousSDKError.endpointNotCreated`: If the endpoint has not yet been created. ``` -------------------------------- ### Presenting AuviousConferenceVCNew Source: https://context7.com/auvious/auvious-sdk-ios/llms.txt Instantiate AuviousConferenceVCNew with a configuration object and present it modally. Implement AuviousSimpleConferenceDelegate to handle call outcomes. ```swift import AuviousSDK // MARK: - Presenting the built-in conference UI class ViewController: UIViewController { func startConference() { var config = AuviousConferenceConfiguration() // --- Connection --- config.username = "ticket-or-username" config.password = "" // empty when using ticket auth config.grantType = "password" config.clientId = "customer" // registered client ID config.conference = "room-name" // conference room to join config.baseEndpoint = "https://auvious.video/" config.mqttEndpoint = "auvious.video" // --- Call behaviour --- config.callMode = .audioVideo // .audio | .video | .audioVideo config.enableSpeaker = true config.backgroundAudioEnabled = true // requires UIBackgroundModes "audio" config.participantName = "Alice" // --- UI controls --- config.conferenceBackgroundColor = .black config.cameraAvailable = true config.microphoneAvailable = true config.speakerAvailable = true config.pipAvailable = true config.screenSharingAvailable = true let conferenceVC = AuviousConferenceVCNew(configuration: config, delegate: self) conferenceVC.modalPresentationStyle = .fullScreen present(conferenceVC, animated: true) } } // MARK: - AuviousSimpleConferenceDelegate extension ViewController: AuviousSimpleConferenceDelegate { /// Conference ended normally (remote hangup, host ended, or local hangup). func onConferenceSuccess() { dismiss(animated: true) } /// Authentication failure, network error, missing permissions, etc. func onConferenceError(_ error: AuviousSDKGenericError) { dismiss(animated: true) switch error { case .AUTHENTICATION_FAILURE: showAlert("Authentication failed — check your ticket/credentials.") case .PERMISSION_REQUIRED: showAlert("Camera or microphone permission denied.") case .NETWORK_ERROR: showAlert("Network error. Please check your connection.") case .CONFERENCE_MISSING: showAlert("Conference room not found.") case .CALL_REJECTED: showAlert("Call was rejected.") case .INVALID_TICKET(let ticketId): showAlert("Invalid or expired ticket: \(ticketId)") case .UNKNOWN_FAILURE: showAlert("An unexpected error occurred.") } } } ``` -------------------------------- ### Initialize JSON from Object Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Initialize a JSON object directly from a Swift object. ```swift let json = JSON(jsonObject) ``` -------------------------------- ### Create MQTT 3.1.1 Instance over WebSocket Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/CocoaMQTTWebsocket_IOS13/README.md Instantiate CocoaMQTT with a CocoaMQTTWebSocket socket for MQTT 3.1.1 connections. ```swift ///MQTT 3.1.1 let websocket = CocoaMQTTWebSocket(uri: "/mqtt") let mqtt = CocoaMQTT(clientID: clientID, host: host, port: 8083, socket: websocket) // ... _ = mqtt.connect() ``` -------------------------------- ### Connect with Custom Headers and SSL Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/CocoaMQTTWebsocket_IOS13/README.md Configure custom HTTP headers and enable SSL for the WebSocket connection. This is useful for authentication or specific server requirements. ```swift let websocket = CocoaMQTTWebSocket(uri: "/mqtt") websocket.headers = [ "x-api-key": "value" ] websocket.enableSSL = true let mqtt = CocoaMQTT(clientID: clientID, host: host, port: 8083, socket: websocket) // ... _ = mqtt.connect() ``` -------------------------------- ### Initialize JSON from String Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Initialize a JSON object from a string by first converting it to Data. ```swift if let dataFromString = jsonString.data(using: .utf8, allowLossyConversion: false) { let json = JSON(data: dataFromString) } ``` -------------------------------- ### Push Auvious SDK to Pod Source: https://github.com/auvious/auvious-sdk-ios/blob/master/README.md Publish a new version of the Auvious SDK to the CocoaPods repository. Ensure you have added the podspec repo first. ```bash pod repo push AuviousSDK.podspec --verbose --allow-warnings ``` -------------------------------- ### WebRTC Project Copyright and License Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/Target Support Files/Pods-ExampleSimpleConference/Pods-ExampleSimpleConference-acknowledgements.markdown This snippet contains the copyright notice and license terms for the WebRTC project. It outlines the conditions for redistribution and use in source and binary forms. ```markdown Copyright (c) 2011, The WebRTC project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Google nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ``` -------------------------------- ### joinConference Source: https://context7.com/auvious/auvious-sdk-ios/llms.txt Joins an existing conference room or creates one if it doesn't exist. Upon successful joining, it initiates the publishing of the local media stream. ```APIDOC ## joinConference ### Description Joins an existing (or create-on-join) conference room. On success, start publishing the local stream. ### Method Signature `func joinConference(id: String)` ### Parameters - **id** (String) - The unique identifier of the conference room to join. ``` -------------------------------- ### Handle Incoming Messages with Closures Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/CocoaMQTTWebsocket_IOS13/README.md Configure a closure to handle incoming MQTT messages. This provides an alternative to implementing the CocoaMQTTDelegate protocol for message reception. ```swift mqtt.didReceiveMessage = { mqtt, message, id in print("Message received in topic \(message.topic) with payload \(message.string!)") } ``` -------------------------------- ### Import SwiftyJSON Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Import the SwiftyJSON library to use its functionalities. ```swift import SwiftyJSON ``` -------------------------------- ### Standard JSON Handling in Swift Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Demonstrates the verbose and complex way to handle JSON data using Swift's built-in JSONSerialization, highlighting the need for SwiftyJSON. ```swift if let statusesArray = try? JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [[String: Any]], let user = statusesArray[0]["user"] as? [String: Any], let username = user["name"] as? String { // Finally we got the username } ``` ```swift if let JSONObject = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [[String: Any]], let username = (JSONObject[0]["user"] as? [String: Any])?["name"] as? String { // There's our username } ``` -------------------------------- ### Carthage Integration Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/SwiftyJSON/README.md Instructions for integrating SwiftyJSON into an iOS project using Carthage by adding the specified line to the Cartfile. ```plaintext github "SwiftyJSON/SwiftyJSON" ~> 4.0 ``` -------------------------------- ### Import CocoaMQTT with Swift Package Manager Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/CocoaMQTTWebsocket_IOS13/README.md To use CocoaMQTT in your project, add the package dependency via Xcode's Swift Packages menu and then import the library. ```swift import CocoaMQTT ``` -------------------------------- ### Enable WebSocket Compression Source: https://github.com/auvious/auvious-sdk-ios/blob/master/Example/Pods/Starscream_IOS13/README.md Compression is enabled by default but only used if the server also supports it. You can explicitly enable it by providing a `compressionHandler` during WebSocket initialization. ```swift var request = URLRequest(url: URL(string: "ws://localhost:8080/")!) let compression = WSCompression() let socket = WebSocket(request: request, compressionHandler: compression) ```