ThinCloud

public class ThinCloud: OAuth2TokenDelegate

General container responsible for retaining the ThinCloud and VirtualGateway instances.

  • The ThinCloud SDK singleton.

    Declaration

    Swift

    public static let shared = ThinCloud()
  • The ThinCloud Virtual Gateway singleton.

    Declaration

    Swift

    public let virtualGateway = VirtualGateway()
  • The ThinCloud deployment used.

    Declaration

    Swift

    public private(set) var instance: String!
  • The user signed in to the ThinCloud instance. If nil, no user is signed in.

    Declaration

    Swift

    public private(set) var currentUser = Persistence.cachedUser()
  • The client of the user associated with the current ThinCloud instance. If nil, no user is signed in.

    Declaration

    Swift

    public private(set) var currentClient = Persistence.cachedClient()
  • Configures the ThinCloud singleton with your deployment and client keys.

    Declaration

    Swift

    public func configure(instance: String, clientId: String, apiKey: String)

    Parameters

    instance

    The ThinCloud instance name, i.e. api.instance.yonomi.cloud

    clientId

    The OAuth client key.

    apiKey

    The ThinCloud API key.

  • A convenience method for UIApplication.shared.registerForRemoteNotifications().

    Declaration

    Swift

    public func registerClient()
  • Signs in a user creating a session inside the ThinCloud singleton.

    Declaration

    Swift

    public func signIn(email: String, password: String, completion: @escaping (_ error: Error?, _ user: User?) -> Void)

    Parameters

    email

    The user’s e-mail address.

    password

    The user’s password.

    completion

    The handler called after a sign in attempt is completed.

  • Signs out the user session inside the ThinCloud singleton.

    Declaration

    Swift

    public func signOut()
  • Begins the user password reset process.

    Declaration

    Swift

    public func resetPassword(email: String, completion: @escaping (_ error: Error?) -> Void)

    Parameters

    email

    The user’s e-mail address.

    completion

    The handler called after a reset attempt is completed.

  • Verifies a password change of a user.

    Declaration

    Swift

    public func verifyResetPassword(email: String, password: String, confirmationCode: String, completion: @escaping (_ error: Error?) -> Void)

    Parameters

    email

    The user’s e-mail address.

    password

    The user’s new password.

    confirmationCode

    The confirmation code sent to the user’s e-mail address.

    completion

    The handler called after a sign in attempt is completed.

  • Verifies a new user.

    Declaration

    Swift

    public func verifyUser(email: String, confirmationCode: String, completion: @escaping (_ error: Error?) -> Void)

    Parameters

    email

    The user’s e-mail address.

    confirmationCode

    The confirmation code sent to the user’s e-mail address.

    completion

    The handler called after a sign in attempt is completed.

  • Resends a verification e-mail to new user.

    Declaration

    Swift

    public func resendUserVerification(email: String, completion: @escaping (_ error: Error?) -> Void)

    Parameters

    email

    The user’s e-mail address.

    completion

    The handler called after a sign in attempt is completed.

  • Creates a user.

    Declaration

    Swift

    public func createUser(name: String, email: String, password: String, completion: @escaping (_ error: Error?, _ user: User?) -> Void)

    Parameters

    name

    The user’s name.

    email

    The user’s e-mail.

    password

    The user’s password.

    completion

    The handler called after a user creation attempt is completed.

  • Fetches the signed in user associated with the ThinCloud SDK instance.

    Declaration

    Swift

    public func getUser(completion: @escaping (_ error: Error?, _ user: User?) -> Void)

    Parameters

    completion

    The handler called after a user fetch attempt is completed.

  • Updates a the signed in user associated with the ThinCloud SDK instance.

    Declaration

    Swift

    public func updateUser(_ updates: UserUpdateRequest, completion: @escaping (_ error: Error?, _ user: User?) -> Void)

    Parameters

    updates

    The changes to the user.

    completion

    The handler called after a user update attempt is completed.

  • Deletes the current user associated with the ThinCloud SDK instance.

    Declaration

    Swift

    public func deleteUser(completion: @escaping (_ error: Error?) -> Void)

    Parameters

    completion

    The handler called after a user delete attempt is completed.

  • Fetches all devices associated with the current user.

    Declaration

    Swift

    public func getDevices(completion: @escaping (_ error: Error?, _ device: [Device]?) -> Void)

    Parameters

    completion

    The handler called after a device fetch attempt is completed.

  • Fetches a specified device by its deviceId.

    Declaration

    Swift

    public func getDevice(deviceId: String, completion: @escaping (_ error: Error?, _ device: Device?) -> Void)

    Parameters

    deviceId

    The ThinCloud generated device identifier.

    completion

    The handler called after a device fetch attempt is completed.

  • Creates a device.

    Declaration

    Swift

    public func createDevice(device: DeviceCreateRequest, completion: @escaping (_ error: Error?, _ device: Device?) -> Void)

    Parameters

    device

    The device to create.

    completion

    The handler called after a device creation attempt is completed.

  • Updates a device.

    Declaration

    Swift

    public func updateDevice(deviceId: String, updates: DeviceUpdateRequest, completion: @escaping (_ error: Error?, _ device: Device?) -> Void)

    Parameters

    deviceId

    The ThinCloud generated device identifier.

    updates

    The changes to the device.

    completion

    The handler called after a device update attempt is completed.

  • Deletes a device.

    Declaration

    Swift

    public func deleteDevice(deviceId: String, completion: @escaping (_ error: Error?) -> Void)

    Parameters

    deviceId

    The ThinCloud generated device identifier.

    completion

    The handler called after a device deletion attempt is completed.

  • Fetches all clients associated with the current user.

    Declaration

    Swift

    public func getClients(completion: @escaping (_ error: Error?, _ clients: [Client]?) -> Void)

    Parameters

    completion

    The handler called after a client fetch attempt is completed.