Giter VIP home page Giter VIP logo

flutter-sms-retriever's Introduction

Android Sms Retriever

Fork  Star  Watches  pub package  Example

Flutter plugin for retrieving OTP code sent in sms automatically and without getting SMS permission in Android. This package has support for Smart Lock credentials, you can use for storing user's phone number and retrieving whenever you want. Read more here

Example

example

Getting Started

Install

dependencies:
  android_sms_retriever: ^1.1.1

Import

import 'package:android_sms_retriever/android_sms_retriever.dart';

App signature

Use this function to get application signature. App signature should be placed at end of SMS so SmsRetriever API can verify SMS is sent from your server.

String appSignature = await AndroidSmsRetriever.getAppSignature();

Request phone number

You can request android to open a dialog with user's phone numbers, then user can select one.

String phoneNumber = await AndroidSmsRetriever.requestPhoneNumber();

Store phone number

You can store user's phone number to use later, For example: When user uninstalls application and installs again. You should pass your application's website URL and phone number to this function.

await AndroidSmsRetriever.storePhoneNumber('https://arsam.me','09027777254');

Retrieve stored phone number

To retrieve stored phone number use this function. You should pass your application's website URL to this function.

String phoneNumber = await AndroidSmsRetriever.retrieveStoredPhoneNumber('https://arsam.me');

Delete stored phone number

To delete stored phone number use this function. You should pass your application's website URL and phone number to this function.

await AndroidSmsRetriever.deleteStoredPhoneNumber('https://arsam.me','09027777254');

Start listening for SMS

Use this function to start listening for an incoming SMS. When sms received message will be returned.

String message = await AndroidSmsRetriever.startSmsListener();

Close receiver after getting SMS

Stop listening for SMS. It's better to stop listener after getting message.

AndroidSmsRetriever.stopSmsListener();

Request one time SMS consent

Using this function, when sms received android will ask user to let application use message and extract code, even if sms message does not contain application signature. You can pass sender phone number in order to detect messages sent from specific sender.

String smsCode = await AndroidSmsRetriever.requestOneTimeConsentSms('+9850003001');

Note

SMS format should be like this :

Your example code is: 123456

appSignature

flutter-sms-retriever's People

Contributors

arsamme avatar chendong0120 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.