Digipass S3 is now DigipassONE. This section is currently being updated to reflect our new name.

Replacing the OTP method UI

Prev Next

The App SDK provides a default UI class for the OTP registration and authentication method that adopts the NNLIOtpLiveData protocol. This collects the person's phone number or email. This is the first screen in the default UI for SMS OTP:

The class that implements your custom UI must also adopt the NNLIOtpLiveData protocol. In addition, an object of Digipass S3's default UI class is created by Digipass S3's MethodUIFactory. Therefore, you must define your own factory class to create an object of your custom UI.

The following steps take you through defining your custom UI class and your custom factory class.

  1. Create a custom class that implements your UI.

  2. Declare that your custom class adopts the NNLIOtpLiveData protocol. Define the following methods in your custom UI class: onGetIdentifer(), onConfirmIdentifier(), onGetCode(), onFinish(). These method definitions ensure that your class adopts the NNLIOtpLiveData protocol.

  3. Define a new factory class as a subclass of NNLMethodUIFactory. For example, call this new class SampleMethodUiFactory.

  4. Override your new factory's createMethodUI() method. Refer to SampleMethodUiFactory.swift in the Tutorial App for details on how to write this method.

  5. When you create your factory, set your SampleMethodUiFactory class to the NNLMethodUIFactory instance.

let defaultFactory = NNLMethodUIFactory.getInstance()
let factory = SampleMethodUiFactory(factory: defaultFactory)
NNLMethodUIFactory.setInstance(factory)

Refer to the Client API Docs for the NNLIOtpLiveData protocol for more details.

Working examples in Tutorial app

  • Refer to files SampleMethodUiFactory.swift and SampleOtpUi.swift for an example implementation.