Android SMS based user verification generic flow

166 views Asked by At

I have a few different Android apps which use Android SMS Retriever API, to perform SMS-based user verification. I am wondering if there is a consistent way to authenticate user via SMS and not implement it with every app I am creating. I was thinking about creating an authentication app and move all the implementation there which each of the apps can call or some clever way to consolidate the onboarding SMS verification flow. What are some good practices/recommendations to achieve this.

1

There are 1 answers

0
RobertoAllende On

I think you want to put the SMS functionality in an Android Library and reuse that library in all your apps.

As Android Documentation states:

An Android library is structurally the same as an Android app module. It can include everything needed to build an app, including source code, resource files, and an Android manifest. However, instead of compiling into an APK that runs on a device, an Android library compiles into an Android Archive (AAR) file that you can use as a dependency for an Android app module.

So, the trick is to create a New Module that includes the business logic and the UI you need to reuse and then, you add it as dependency to the other apps.