Android용 플러터 플러그인으로 디바이스의 SMS 수신함에 쉽게 접근할 수 있도록 합니다. 개발자가 사용자의 전화기에서 수신된 텍스트 메시지를 쿼리하고 가져올 수 있게 하여 앱 내에서 SMS 내용을 읽는 간단한 방법을 제공합니다. Android 전용으로 설계되어 신뢰성 있는 메시지 검색을 보장하기 위해 네이티브 Android API를 활용합니다. SMS 기반 인증 또는 메시지 모니터링이 필요한 애플리케이션에 적합합니다.
사용 사례
OTP 인증을 위해 SMS 메시지 읽기
메시지 앱에서 수신 메시지 모니터링
SMS 데이터 수집 자동화
은행 또는 서비스 앱과의 통합
주요 기능
안드로이드 전용 지원
수신함 쿼리용 간단한 API
SMS 콘텐츠 및 메타데이터에 대한 액세스
복잡한 네이티브 코드가 필요하지 않습니다
경량이며 통합이 쉬움
적합한 대상
SMS 인증이 필요한 앱
메시징 도구를 개발하는 개발자
자동 SMS 읽기 필요 프로젝트
Android 중심의 Flutter 애플리케이션
고려 사항
안드로이드 기기에서만 작동합니다
SMS 액세스를 위한 런타임 권한이 필요합니다
모든 안드로이드 버전에서 작동하지 않을 수 있습니다
사용자는 SMS 권한을 명시적으로 부여해야 합니다
받은 메일함 메시지만 제한
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Flutter SMS Inbox
Flutter android SMS inbox library based on Flutter SMS.
Installation
Add the package to your project by the following command:
flutter pub add flutter_sms_inbox
Add permission_handler package to your project because this package uses it for permission handling:
flutter pub add permission_handler
Add the following permission to your AndroidManifest.xml file:
You need to request the SMS permission before dealing with the package. You can do it by using the permission_handler package. Here is an example of how to request the permission:
import'package:permission_handler/permission_handler.dart';
Future<bool> getSmsPermission() async {
var permissionStatus = awaitPermission.sms.status;
if (permissionStatus.isGranted) {
returntrue;
} elseif (permissionStatus.isDenied) {
// We didn't ask for permission yet or the permission has been denied before but not permanently.if (awaitPermission.sms.request().isGranted) {
returntrue;
}
} elseif (permissionStatus.isPermanentlyDenied) {
// The user opted to never again see the permission request dialog for this// app. The only way to change the permission's status now is to let the// user manually enable it in the system settings.openAppSettings();
}
returnfalse;
}
Security notes
This plugin reads sensitive user data (SMS metadata and message body). Request READ_SMS only when needed and explain the purpose clearly to users.
Do not log, persist, or transmit SMS message content unless your app has a clear product and compliance need.
Handle permission denial gracefully. Calls may fail if SMS permission is revoked or restricted by device policy.
Error handling
Query calls can return structured platform errors:
permission_denied: READ_SMS was denied or unavailable.
invalid_arguments: one or more query arguments had an unexpected type or invalid value (start >= 0, count == -1 or >= 0, thread_id == -1 or >= 0, kinds must not be empty).
invalid_response: platform returned an unexpected payload shape.
query_failed: an unexpected platform failure occurred while querying SMS.
Querying SMS messages
Add the import statement for sms and create an instance of the SmsQuery class:
The method querySms from the SmsQuery class returns a list of sms depending of the supplied parameters. For example, for querying all the sms messages sent and received write the followed code:
start and count are applied globally across the ordered kinds list (not per kind). For example, with kinds: [SmsQueryKind.inbox, SmsQueryKind.sent], start: 2, and count: 5, the query skips the first 2 messages across inbox then sent, and returns up to the next 5 messages from that combined ordered sequence.
For safety, queries are bounded in the Dart layer:
If count is omitted (or negative), the query uses a default cap of 200 messages.
Oversized request windows are clamped to 1000 messages before native queries are made.
The Android native layer also applies a defensive fallback cap of 1000 messages if requests arrive with unbounded or oversized values.
Privacy-safe usage patterns
Keep queries narrow: always set count and use address/threadId filters where possible.
Avoid rendering full SMS bodies by default in UI. Prefer a masked preview and add explicit user action before showing full content.
Do not log SMS body or sender details in production builds.
Do not persist or transmit SMS content unless it is strictly required and compliant with your product/privacy obligations.
You can also query all the sms messages sent and received from a specific contact: