SMS OTP Fetcher library for android

Published by Kapil Mohan on

A library for implementing interception of SMS with a verification code using a few lines of code.

NB:- As per the new Playstore policy, its not allowed to use SMS Receiver or Read Permission for fetching otp.

Read more at:-

https://play.google.com/about/privacy-security-deception/permissions/

Find an alternative here:

https://developers.google.com/identity/sms-retriever/overview

Use sms fetching functionality only for Academic / Projects which won’t be published on play store.

Github link:- https://github.com/stfalcon-studio/SmsVerifyCatcher

Requires permission for receiving and reading sms.

declare smsVerifyCatcher

onCreate() initialise smsVerifyCatcher

Codes for parsing verification code, starting and stopping catcher and for android runtime permissions. Place it after onCretae() method

Hacks for using directly from fragments

  • Declare smscatcher in activity
  • find view in fragment, acces by typecasting activity
  • start catcher in fragment start.
  • use permissions directly in activity

In fragment onCreateView

In activity place codes after onCreate Method

declare catcher in activity

parseString can be placed either in activity or in fragment

You can set phone number filter:

or set message filter via regexp:

Library Details:-

Download Sample Project


Kapil Mohan

Like to add color to developers life and apps. Can create smile using Android, iOS, PHP, codeignitor, web technologies, etc... Feel free to contact me at [email protected] .