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
createVerification
methods of global SDK object. Each method has its own builder instance following Fluent Builder Pattern . There is also averification-all
module that can be used to simplify creation of different verification method objects with similar configuration parameters. -
Config
object concept passed to each verification has been split to GlobalConfiguration (one for the entire SDK) and method specific configuration instances. -
Single
VerificationListener
holding callbacks connected with the entire verification flow were divided into method specificInitiationListener
notifying about the verification request result and theVerificationListener
which 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
PhoneNumberFormattingTextWatcher
were removed starting from API level 21. There are methods with the exact same functionality already built-in to the Android SDK.