パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.0.7

sms_sender_background

Dual SIMカード、権限処理、マルチパートメッセージをサポートするSMSメッセージの送信用Flutterプラグイン。

Android
30日間ダウンロード
54
いいね数
15
Pub ポイント
160

パッケージをインストール

flutter pub add sms_sender_background

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

sms_sender_background は、Android向けに設計されたFlutterプラグインで、デュアルSIMカード、自動権限処理、マルチパートメッセージ送信をサポートしています。バックグラウンドプロセスでのスムーズなSMS機能を可能にし、ユーザーの干渉なしに信頼性の高いメッセージ送信が必要なアプリケーションに最適です。このプラグインはAndroidのテレフォニーAPIとシームレスに統合され、メッセージの複数部分への分割やSIM選択といった複雑な状況を管理します。自動またはスケジュールされたSMS通知が必要なアプリに特に役立ちます。

用途

  • 自動SMS通知
  • デュアルSIMメッセージルーティング
  • バックグラウンドSMS配信
  • スケジュールされたメッセージ
  • マルチパートSMS対応
  • SMSベースの認証

主な機能

  • デュアルSIMカード対応
  • 自動権限管理
  • マルチパートメッセージ処理
  • バックグラウンド実行機能
  • SIM選択制御
  • Android専用の互換性

適している対象

  • 自動SMSを必要とするアプリ
  • 通知システム
  • 二要素認証
  • 現場サービスアプリケーション
  • メッセージユーティリティ
  • バックグラウンドタスクの統合

注意事項

  • Android専用プラットフォーム
  • 実行時権限が必要です
  • SMS機能に制限されています
  • iOS 対応なし
  • デバイスの電話機能に依存します
  • デュアルSIMデバイス用に追加の設定が必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

SMS Sender Background

A Flutter plugin for sending SMS messages with support for dual SIM cards, permission handling, and multi-part messages.

Features

  • Send SMS messages from your Flutter app
  • Support for dual SIM cards (specify SIM slot)
  • Automatic permission handling (request and check SMS permissions)
  • Support for long messages (automatically splits into multi-part messages)
  • Error handling and status reporting

Getting Started

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  sms_sender_background: ^1.0.5
Android Setup

Add the following permissions to your Android Manifest (android/app/src/main/AndroidManifest.xml):

<uses-permission android:name="android.permission.SEND_SMS"/>
<!-- Optional: Required only for dual SIM support -->
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

Note about READ_PHONE_STATE permission:

  • This permission is optional and only needed if you want to use dual SIM functionality
  • If not granted, the plugin will automatically fall back to using the default SIM card
  • This ensures the plugin works reliably even on devices with stricter security policies or when distributed outside Google Play
Usage
import 'package:sms_sender_background/sms_sender.dart';;

// Create an instance
final smsSender = SmsSender();

// Check SMS permission
bool hasPermission = await smsSender.checkSmsPermission();

// Request permission if needed
if (!hasPermission) {
  hasPermission = await smsSender.requestSmsPermission();
}

// Optional: Check and request READ_PHONE_STATE permission for dual SIM support
// If not granted, the plugin will use the default SIM card
bool hasPhoneStatePermission = await smsSender.checkPhoneStatePermission();
if (!hasPhoneStatePermission) {
  hasPhoneStatePermission = await smsSender.requestPhoneStatePermission();
}

// Send SMS
if (hasPermission) {
  try {
    bool success = await smsSender.sendSms(
      phoneNumber: '+1234567890',
      message: 'Hello from Flutter!',
      simSlot: 0, // Optional: specify SIM slot (0 or 1)
    );
    print('SMS sent: $success');
  } catch (e) {
    print('Error sending SMS: $e');
  }
}

Additional Features

Dual SIM Support

To send an SMS using a specific SIM card:

// Optional: Request READ_PHONE_STATE permission for dual SIM support
bool hasPhoneStatePermission = await smsSender.checkPhoneStatePermission();
if (!hasPhoneStatePermission) {
  hasPhoneStatePermission = await smsSender.requestPhoneStatePermission();
}

await smsSender.sendSms(
  phoneNumber: '+1234567890',
  message: 'Hello!',
  simSlot: 1, // Use second SIM card
);

Important Notes:

  • Dual SIM support requires the READ_PHONE_STATE permission
  • If this permission is not granted, the plugin will automatically fall back to using the default SIM card
  • This ensures compatibility across all devices, including those with stricter security policies
  • The fallback mechanism works reliably even when apps are installed from unknown sources
Long Messages

The plugin automatically handles long messages by splitting them into multiple parts:

await smsSender.sendSms(
  phoneNumber: '+1234567890',
  message: 'A very long message that will be automatically split...',
);

Error Handling

The plugin provides detailed error information through exceptions:

  • PlatformException with code "PERMISSION_DENIED" when SMS permission is not granted
  • PlatformException with code "INVALID_ARGUMENT" when phone number or message is empty
  • PlatformException with code "SMS_SEND_ERROR" when SMS sending fails

Contributing

Feel free to contribute to this project:

  1. Fork it
  2. Create your feature branch (git checkout -b feature/my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/my-new-feature)
  5. Create a new Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details

カテゴリー

依存関係

依存関係一覧 1 件

  • plugin_platform_interface^2.0.2

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。