readotp 1.0.1+9 copy "readotp: ^1.0.1+9" to clipboard
readotp: ^1.0.1+9 copied to clipboard

PlatformAndroid

A flutter plugin that reads incoming SMS on device as a broadcast stream.

readotp #

A Flutter plugin to read incoming SMS (OTP) messages on the device as a broadcast stream.

Usage #

  1. Request SMS Permission

    • Use the permission_handler package to request SMS permissions at runtime.
    • On Android, add the following to your AndroidManifest.xml:
      <uses-permission android:name="android.permission.RECEIVE_SMS" />
      <uses-permission android:name="android.permission.READ_SMS" />
      
  2. Create and Start the Plugin

    final readOtp = ReadOtp();
    await Permission.sms.request(); // Request permission before starting
    readOtp.start();
    
  3. Listen to the SMS Stream

    readOtp.smsStream.listen((sms) {
      print(sms.body);
      print(sms.sender);
      print(sms.timeReceived);
    });
    
  4. Dispose When Done

    readOtp.dispose();
    

That's all you need to do!

For a complete example, see example/lib/main.dart.

4
likes
160
points
14
downloads

Publisher

verified publisherakshayjayale.com

Weekly Downloads

A flutter plugin that reads incoming SMS on device as a broadcast stream.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on readotp