Verification

public protocol Verification

Protocol for a Verification.

  • Initiate the verification.

    A request will be sent to the Sinch backend to initiate the verification. A SMS-based verification will initiate sending an SMS to the destination phone number. A Callout-based verification will initiate placing phone call the destination phone number.

    Declaration

    Swift

    func initiate(_ completion: @escaping (InitiationResult, Error?) -> Void);

    Parameters

    completion

    Closure that will be invoked upon completion.

  • Complete the verification by verifying the verification code sent to the user.

    Declaration

    Swift

    func verify(_ code: String, completion: @escaping (Bool, Error?) -> Void);

    Parameters

    code

    Verification code that the user received and have given as input to the application.

    completion

    Closure that will be invoked upon completion.

  • Cancel the verification (client-side only).

    Note that cancelling is a client-side only action, i.e. it will not send any further requests to the Sinch platform and it does not guarantee that a SMS or a callout won’t be made to the user’s device. What it will do is cancel any long-polling requests that this verification instance may be maintaining (e.g. a callout verification is performing polling to query the Sinch platform for the status of the verification)

    If the verification is in a state where a completion handler have been specified, the handler will be invoked with the error code SINVerificationErrorCancelled.

    Declaration

    Swift

    func cancel();
  • Specify a dispatch queue on which completion blocks should be invoked on.

    Unless specified, the main queue is used by default.

    This must be set before initiate(1) or verify(2) is called.

    Declaration

    Swift

    func completionQueue(_ queue: DispatchQueue);

    Parameters

    queue

    GCD dispatch queue

  • Specify a specific Sinch environment host. (This is not mandatory.)

    This must be set before initiate(1) or verify(2) is called.

    Declaration

    Swift

    func environmentHost(_ host: String);

    Parameters

    host

    Host for base URL for the Sinch API environment to be used. E.g. ‘sandbox.sinch.com’