搜索插件、代码仓与 APP 分类

sms_user_consent 封面
插件详情v0.1.0

sms_user_consent

请求用户的电话号码(支持双卡)和/或同意读取短信,而无需添加任何权限

Android
近 30 天下载
93
喜欢数
85
Pub 分数
160

安装插件

flutter pub add sms_user_consent

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

sms_user_consent 包使 Flutter 应用能够在不请求显式权限的情况下,请求用户的电话号码和/或同意读取 Android 上的短信。它利用了 Android 内置的短信权限系统,允许用户通过标准系统对话框授予访问权限。该包支持双卡设备,确保在各种 Android 硬件上的兼容性。它非常适合需要 OTP 验证或基于短信的身份验证的应用程序,简化流程的同时保持隐私和安全。

适合场景

  • OTP 验证
  • 基于短信的认证
  • 双卡设备支持
  • 保护隐私的短信访问
  • 用户同意收集

主要特点

  • 无需额外权限
  • 双卡兼容
  • 仅支持 Android
  • 系统级同意对话框
  • 电话号码检索

适合对象

  • 需要OTP输入的应用
  • 认证流程
  • 无需清单权限的短信读取
  • 面向Android的应用程序
  • 最小权限应用

使用建议

  • 仅限 Android
  • 需要用户交互
  • 仅限短信读取
  • 不支持 iOS
  • 依赖系统级同意

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

sms_user_consent

Request user's phone number (supports dual sim) and/or consent to read SMS without adding any permissions, using Android's SMS User Consent API

Screenshots

Steps to use

1] Create an instance, optionally supply phone number listener and sms listener

SmsUserConsent smsUserConsent = SmsUserConsent(
        // optionally, do something when user selects a number.
        // You can even add/update this listener later on by simply 
        // calling smsUserConsent.updatePhoneNumberListener(updatedListener)
        phoneNumberListener: () {},
        
        // optionally, do something when user receives sms.
        // You can even add/update this listener later on by simply 
        // calling smsUserConsent.updateSmsListener(updatedListener)
        smsListener: () {}
);

2a] OPTIONAL : Request user's phone number

smsUserConsent.requestPhoneNumber();

Once the user selects a phone number, it can be accessed as

smsUserConsent.selectedPhoneNumber;

2b] OPTIONAL : Request to receive SMS

smsUserConsent.requestSms(); 

or you can specify the phone number you wish to capture the SMS from

smsUserConsent.requestSms(senderPhoneNumber: sender_number);

Once the user receives a SMS and the user taps Allow, it can be accessed as

smsUserConsent.receivedSms;

3] Finally, dispose the instance

smsUserConsent.dispose();
Note

As per the SMS User Consent API, message will be received by the plugin only if it meets these criteria:

  • The message contains a 4-10 character alphanumeric string with at least one number.
  • The message was sent by a phone number that's not in the user's contacts.
  • If you specified the sender's phone number, the message was sent by that number.

Contributing

  • Found a bug or idea to improve the plugin? Send a PR.
  • Found this plugin helpful and want to thank me? I love :coffee:
  • Want to hire me for a gig? Let's talk on LinkedIn

License

MIT © 2020 Harsh P

所属分类

源码仓库

使用此插件的项目

暂无相关数据。