Skip to content

Banuba/BanubaTokenStorageSDK-iOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

Banuba TokenStorageSDK. API Reference.

BanubaTokenStorageSDK allows you to store your token at server side via module API. For example you could use interaction with Firebase

Following protocol requires creation of the instance inherited from it and then passed to VideoEditorTokenProvider init.

/// Alows you to create database manager with host application implementation.
public protocol TokenProvidable: AnyObject {
  /// Observes token from remote database with multiple events.
  /// - parameters:
  ///    - succesEvent: Succes completion with optional token recieving.
  ///    - errorEvent: Error completion whenever some issues occurs.
  func observeToken(
    succesEvent: @escaping (_ token: String?) -> Void,
    errorEvent:  @escaping (_ error: Error) -> Void
  )
}

VideoEditorTokenProvider is the main API for token downloading usage.

/// Token provider which interact with remote database public private(set) var tokenProvider: TokenProvidable?

Initializer

  /// VideoEditorTokenProvider constructor
  /// - Parameters:
  ///   - tokenProvider: The instance of entity which extend by TokenProvidable interface.
  public init(
    tokenProvider: TokenProvidable?
  )

Loading token

  /// Receiving token from local plist file or via remote database
  /// - Parameters:
  ///   - completion: The completion handler is called with optional token and some optional errors.
  ///   - error: Description of any error that might occur.
  ///   - token: Token used to initialize the BanubaVideoEditor.
  public func loadToken(
    completion: @escaping (_ error: TokenProviderErrorType?, _ token: String?) -> Void
  )

TokenProviderErrorType

// error types
  case databaseError(error: Error?)    /// Have't permission to access database
  case databaseSettingsError           /// TokenSnapshot and targetUrl are not setted
  case localTokenNotFound              /// Local token is nil or empty
  case snapshotError                   /// Snapshot is nil or has incorrect type
  case noInternetConnection            /// There is no internet connection