The migration process
In order to migrate from version 1 to 2.*.* of the SDK, one needs to change how Verification objects are created:
val verification =
SinchVerification.createSmsVerification(config, phoneNumberInE164, listener)
//to
val verification = SmsVerificationMethod.Builder()
.config(/* Method config instance */)
.initiationListener(/* Initiation listener instance */)
.verificationListener(/* Verification listener instance */)
.build()See the verification process section for more details.
The process is a little more complex than simply copy-paste, as the SDK architecture has changed. The main differences are as follows:
- Each verification is shipped in a different module, allowing your app to declare permissions required only by the verification methods that are actually used in your code.
-
There are no
createVerificationmethods of global SDK object. Each method has its own builder instance following Fluent Builder Pattern . There is also averification-allmodule that can be used to simplify creation of different verification method objects with similar configuration parameters. -
Configobject concept passed to each verification has been split to GlobalConfiguration (one for the entire SDK) and method specific configuration instances. -
Single
VerificationListenerholding callbacks connected with the entire verification flow were divided into method specificInitiationListenernotifying about the verification request result and theVerificationListenerwhich is now responsible only for callbacks connected with second phase of verification (validating the code). Passing both listeners to builder is optional, however, it's recommended. -
Some helper utility classes such as
PhoneNumberFormattingTextWatcherwere removed starting from API level 21. There are methods with the exact same functionality already built-in to the Android SDK.