Skip to content

Latest commit

 

History

History
275 lines (224 loc) · 8.86 KB

README.md

File metadata and controls

275 lines (224 loc) · 8.86 KB

ScreenMeetSDK

Version License Platform

ScreenMeet

ScreenMeet.com

Quick start

Start ScreenMeet session

let sessionCode = "123456" // session code provided by support agent
ScreenMeet.shared.connect(code: sessionCode) { result in
    switch result {
        case .success:
            print("Session started!")
        case .failure(let error): 
            //error describes the reason why session is not started
            print("Session start failed: \(error)")
    }
}

Stop ScreenMeet session

ScreenMeet.shared.disconnect()

Pause | Resume ScreenMeet session

ScreenMeet.shared.session?.pause() //pause

ScreenMeet.shared.session?.resume() //resume

Example

To run the example project, clone the repo, and run pod install from the Example directory first. More advanced sample with SwiftUI see in FullExample application.

Requirements

Minimum iOS version
ScreenMeetSDK iOS 12.0
Example iOS 13.0
FullExample iOS 13.0

Installation

ScreenMeetSDK is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ScreenMeetSDK'

Also bitcode should be disabled. It can be done manualy in xCode, or add the following lines at the end of your pod file

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

Session Lifecycle

Organization Key

To start work with SDK organizationKey (mobileKey) is required

//Set organization mobile Key
ScreenMeet.shared.config.organizationKey = yourMobileAPIKey //provided by ScreenMeet

Start session

let sessionCode = "123456" // session code provided by support agent
ScreenMeet.shared.connect(code: sessionCode) { result in
    switch result {
        case .success(let session):
            print("Session started!")
        case .failure(let error): 
            //error describes the reason why session is not started
            print("Session start failed: \(error)")
    }
}

In case .success session object is returned Anytime you can get session object by

ScreenMeet.shared.session

if value of ScreenMeet.shared.session is nil the session in not started of already finished

In case of .failure here is the list of posible reasons

public enum SessionError: Error {
    case incorrectSessionCode      // Incorrect session code or expired session code
    case connectionTimeout         // Can't connect to server
    case sessionNotFound           // Incorrect session code or expired session code
    case sessionAlreadyConnected   // Session with specified code already started
    case incorrectOrganizationKey  // Wrong organization key (mobileKey) value
    case captureFailed             // Can't start capturing or user disallowed screen capturing
}

Stop session

To stop session the following command should be used

ScreenMeet.shared.disconnect()

It will ask user to confirm session stop and after agreement session will be stoped.

Pause/Resume session

ScreenMeet.shared.session?.pause() // Pause session

ScreenMeet.shared.session?.resume() // Resume session

Actual session state

ScreenMeet.shared.session?.lifecycleState

Possible values

public enum State {
    case streaming // Session stream is acvive
    case inactive  // Session stream is not started or already stopped
    case pause     // Session is active but stream is paused
}

Track session state changing

To track session state change LifecycleListener should be registered

ScreenMeet.shared.registerLifecycleListener<T: LifecycleListener>(_ lifecycleListener: T)

The following protocol should be implemented

/// Listener for lifcycle-related state of for the session
public protocol LifecycleListener: class {
    
    var lid: UUID { get }
    
    /// Sesson stream was started or restored
    /// - Parameter oldState:        Previous state value
    /// - Parameter streamingReason: Reason why state was changed
    func onStreaming(oldState: ScreenMeet.Session.State, streamingReason: ScreenMeet.Session.State.StreamingReason)
        
    /// Sesson stream was started or restored
    /// - Parameter oldState:        Previous state value
    /// - Parameter inactiveReason:  Reason why state was changed
    func onInactive(oldState: ScreenMeet.Session.State, inactiveReason: ScreenMeet.Session.State.InactiveReason)
    
    /// Sesson stream was started or restored
    /// - Parameter oldState:        Previous state value
    /// - Parameter pauseReason:     Reason why state was changed
    func onPause(oldState: ScreenMeet.Session.State, pauseReason: ScreenMeet.Session.State.PauseReason)
    
    /// Is called when application fased with network issues and trys to restore connection
    func networkDisconnect()
    
    /// Is called when application restored network connection
    func networkReconnect()
}

Track participants

To track who joins of leaves the session

ScreenMeet.shared.registerSessionEventListener<T: SessionEventListener>(_ sessionEventListener: T)

and implement

public protocol SessionEventListener: class {
    
    var sid: UUID { get }
    
    /// Called when a participant-related action occurs
    /// - Parameter participant the participant
    /// - Parameter participantAction the action that occurred
    func onParticipantAction(participant: ScreenMeet.Session.Participant, participantAction: ScreenMeet.Session.ParticipantAction)
}

where ScreenMeet.Session.Participant and ScreenMeet.Session.ParticipantAction are

        public struct Participant: Identifiable, Equatable {
            
            public var id: String
            
            public var name: String
            
            public static func == (lhs: Self, rhs: Self) -> Bool {
                return lhs.id == rhs.id
            }
        }
        
        /// The actions that may happen for a participant
        public enum ParticipantAction {
            /// The participant was added
            case added
            /// The participant was removed
            case removed
            /// The audio was muted for the participant
            case audioMuted
            /// The audio was unmuted for the participant
            case audioUnmuted
        }

Custom Dialogs

In case you need to change style of SDK's user interaction, use

ScreenMeet.shared.interface = MyCustomDialogs()

where MyCustomDialogs() should fit protocos ScreenMeetUIProtocol

/// Implement ScreenMeetUI protocol to implement all user interactions in style of your application UI
public protocol ScreenMeetUIProtocol {
    
    /// Display a dialog requesting a session code from the user.
    func showSessionCodeDialog(completion: @escaping (String) -> Void)
    
    /// Display a dialog requesting their approval for screen sharing.
    func showAppMirrorPermissionDialog(completion: @escaping (Bool) -> Void)
    
    /// Display a dialog requesting their approval for disconnect session.
    func showDisconnectSessionDialog(completion: @escaping (Bool) -> Void)
    
    /// Display a dialog requesting their approval for laser pointer.
    func showLaserPointerPermissionDialog(completion: @escaping (Bool) -> Void)
    
    /// Display a dialog requesting approval to stop laser pointer.
    func dismissLaserPointerPermissionDialog()
}

for more details see file CustomDialogs.swift in FullExample app

Configuration

Logging level

Represent the severity and importance of log messages ouput

ScreenMeet.shared.config.loggingLevel = .debug

Possible values:

public enum LogLevel {
    /// Information that may be helpful, but is not essential, for troubleshooting errors
    case info
    /// Verbose information that may be useful during development or while troubleshooting a specific problem
    case debug
    /// Designates error events that might still allow the application to continue running
    case error
}

Custom Endpoint URL

Set custom endpoint URL

ScreenMeet.shared.config.endpoint = yourEndpointURL

License

ScreenMeetSDK is available under the MIT license. See the LICENSE file for more info.