CPAuthenticationService
@objc
public class CPAuthenticationService : NSObject
Manages authentication processes and connection.
Since
1.0.0-
Notifies on the connection status changes in CPaaS instance.
Declaration
Swift
@objc public var delegate: CPAuthenticationDelegate!
-
Current connection status of the CPaaS instance.
Declaration
Swift
@objc public internal(set) var connectionState: CPConnectionState { get set }
Return Value
ConnectionState
-
Connection Blocks are invoked when connection operations are called.
Declaration
Swift
public typealias ConnectionBlock = (_ error: CPError?, _ channelInfo: String?) -> ()
Parameters
error
If operation fails returns as CPError, otherwise returns nil
channelInfo
If operation succeeds, returns channelInfo for re-connecting same websocket.
-
Disconnection Block is invoked when disconnection operations are called.
Declaration
Swift
public typealias DisconnectionBlock = (_ error: CPError?) -> ()
Parameters
error
If operation fails returns as CPError, otherwise returns nil
-
Initializes authentication instance with given configuration.
Declaration
Swift
public init(userInfo: CPUserInfo, services: [CPServiceProtocol])
Parameters
userInfo
User Information
services
Array of services that the application has configured for use.
-
Replaces existing access token with the new token
Declaration
Swift
@objc public func setToken(_ accessToken: String)
Parameters
accessToken
An access token for the user with the provided user Id
-
Connects CPaaS with Id Token, Access token and life-time
Declaration
Swift
@objc public func connect(idToken: String, accessToken: String, lifetime: Int, completion: @escaping ConnectionBlock)
Parameters
idToken
The idtoken for the user.
accessToken
An access token for the user with the provided user Id
completion
Invokes ConnectionBlock when operation is finished
-
Connects CPaaS with Id Token and life-time
Declaration
Swift
@objc public func connect(idToken: String, lifetime: Int, completion: @escaping ConnectionBlock)
Parameters
idToken
The idtoken for the user.
lifetime
The time in seconds until websocket disconnects
completion
Invokes ConnectionBlock when operation is finished
-
Tries to connect existing websocket, if fails triggers new connection request with given access token
Declaration
Swift
@objc public func connect(idToken: String, accessToken: String, lifetime: Int, channelInfo: String, completion: @escaping ConnectionBlock)
Parameters
idToken
The idtoken for the user.
accessToken
An access token for the user with the provided user Id
lifetime
The time in seconds until websocket disconnects
channelInfo
String that contains channel information
completion
Invokes ConnectionBlock when operation is finished
-
Tries to connect existing websocket, if fails triggers new connection request
Declaration
Swift
@objc public func connect(idToken: String, lifetime: Int, channelInfo: String, completion: @escaping ConnectionBlock)
Parameters
idToken
The idtoken for the user.
lifetime
The time in seconds until websocket disconnects
channelInfo
String that contains channel information
completion
Invokes ConnectionBlock when operation is finished
-
Disconnectecs from webSocket. This will close the webSocket and other services’ connection.
Declaration
Swift
@objc public func disconnect(completion: @escaping DisconnectionBlock)
Parameters
completion
Disconnection block which is invoked when operation is finished