Auth Module

Privo.auth.getToken() - returns a previously issued token, if it have not expired. Can return nil if token wasn't issued or expired

Privo.auth.logout() - Logout and clean previously issued token.

Privo.auth.renewToken() - Renew token. Return token and it's status.

Privo.auth.renewToken() { tokenStatus in
  let token: String? = tokenStatus?.token
  let isRenewed: Bool? = tokenStatus?.isRenewed
}

Privo.auth.showAuth() - Shows a modal window. User is prompted to Sign In inside this modal window. It returns a new user token as a result

Privo.auth.showRegister() - Shows a modal window. User is prompted to Create an Account inside this modal window
NOTE: this dialog should be closed from completion callback. (This can be done after a short delay. In this case, the user will be able to read content of the congratulations page)

Auth Module Swift UI Components

PrivoAuthButton - swift ui button element that opens a modal window by clicking on it. User is prompted to Sign In inside this modal window. Depending on the integration settings, this button can be customized with branded PRIVO styles by default.

PrivoAuthButton params:
label - customizable Swift UI Label element for the button. It can contains text and any styling inside it.
onFinish - optional completion callback that will provide token if Auth was successful. Otherwise it will provide nil.
closeIcon - optional image for close icon in modal dialog. If nothing is specified, the default image will be used.

  PrivoAuthButton(label: {
    Text("Sign In")
  }, onFinish: { token in
    self.token = token
  }).padding()

PrivoRegisterButton - swift ui button element that opens a modal window by clicking on it. User is prompted to Create an account inside this modal window. Depending on the integration settings, this button can be customized with branded PRIVO styles by default.

PrivoRegisterButton params:
isPresented - binding state value that shows status of modal window presentation. Changed to true automatically when user press button.
Should be changed to false when you want to close the modal dialog.
label - customizable Swift UI Label element for the button. It can contains text and any styling inside it.
onFinish - optional completion handler that will provide token if Auth was successful. Otherwise it will provide nil.
You can change isPresented state value to false inside this callback.
You also can change isPresented after some delay. In this case user will be able to see "Congratulation" page content inside modal dialog.
closeIcon - optional image for close icon in modal dialog. If nothing is specified, the default image will be used.

  PrivoRegisterButton(isPresented: $showRegistration, label: {
    Text("Register")
  }){
    DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) {
      showRegistration = false
    }
  }.padding()