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

パッケージ詳細v0.2.4

sms

Flutterアプリケーション用のSMSライブラリです。SMSメッセージの送信・受信、SMS配信状況の照会、連絡先情報の照会を可能にします。Flutterで完全に機能するSMSアプリを開発するための簡単で親しみやすいAPIを提供しています。

30日間ダウンロード
239
いいね数
118
Pub ポイント
30

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

flutter pub add sms

パッケージ概要

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

Flutter用のSMSパッケージは、SMSメッセージの送信・受信、SMSメッセージの照会、配信状態の確認、連絡先情報へのアクセスを可能にするシンプルなAPIを提供します。最小限のセットアップで完全に機能するSMSアプリケーションの開発を可能にします。使いやすさを重視して設計されており、プラットフォーム固有の複雑さを抽象化し、AndroidおよびiOSでのシームレスな統合を実現しています。基本的なメッセージ操作をサポートし、信頼性の高い通信機能によりアプリの機能を強化します。

用途

  • SMSメッセージングアプリの構築
  • 二要素認証の実装
  • メッセージ配信の自動化
  • 連絡先検索の統合
  • メッセージ配信状態の追跡
  • 通知システムの作成

主な機能

  • SMSメッセージの送信と受信
  • メッセージ配信状態の照会
  • 連絡先情報にアクセス
  • シンプルで直感的な API
  • クロスプラットフォーム互換性
  • Android および iOS のサポート

適している対象

  • メッセージアプリを作成する開発者
  • SMS認証を必要とするアプリ
  • 自動メッセージ処理を必要とするツール
  • 連絡先と統合されたアプリケーション
  • 信頼できるSMS機能を求めるプロジェクト

注意事項

  • AndroidおよびiOSで適切な権限が必要です
  • 基本的なSMS操作に限定
  • バックグラウンドメッセージ処理のための追加構成が必要になる場合があります
  • デバイスレベルのSMSアクセスに依存します
  • 高容量の商業メッセージには適していません

元の README

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

xxhdpi

[UNMAINTAINED] This project is unmaintained

Flutter SMS

This is an SMS library for flutter.

It only support Android for now (I can't do it for iOS because I don't own Mac).

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Installation and Usage

Once you're familiar with Flutter you may install this package adding sms (0.1.4 or higher) to the dependencies list of the pubspec.yaml file as follow:

dependencies:
  flutter:
    sdk: flutter

  sms: ^0.2.0

Then run the command flutter packages get on the console.

Querying SMS messages

Add the import statement for sms and create an instance of the SmsQuery class:

import 'package:sms/sms.dart';

void main() {
  SmsQuery query = new SmsQuery();
}

Getting all SMS messages

List<SmsMessage> messages = await query.getAllSms;

Note: the use of await keyword means that getAllSms is resolved asynchronously and a Future is retorned.

Filtering SMS messages

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:

await query.querySms({
    kinds: [SmsQueryKind.Inbox, SmsQueryKind.Sent]
});

You can also query all the sms messages sent and received from a specific contact:

await query.querySms({
    address: getContactAddress()
});

Getting all Threads Conversations

With SmsQuery you can also get the entire list of conversations:

List<SmsThread> threads = await query.getAllThreads;

Getting the Contact info

Each conversation thread is related with a Contact. The class Contact contains all the info of a thread contact (address, photo, full name). To get access to Contact class you must import 'package:sms/contact.dart' into your dart file:

import 'package:sms/contact.dart';

void main() {
  ...
  Contact contact = threads.first.contact;
  print(contact.address);
}

Querying Contact

You can also query a contact by its address (phone number):

import 'package:sms/contact.dart';

void main() {
  ContactQuery contacts = new ContactQuery();
  Contact contact = await contacts.queryContact(someAddress());
  print(contact.fullName);
}
String getAddress() {...}

The Contact photo

You can retrieve the photo of the contact (full size or thumbnail):

...
Uint8List fullSize = contact.photo.bytes;
Uint8List thumbnail = contact.thumbnail.bytes;

User Profile

Some times it is useful to request basic info of the phone owner, like the contact photo, addresses, etc.

import 'package:sms/contact.dart';

UserProfileProvider provider = new UserProfileProvider();
UserProfile profile = await provider.getUserProfile();
print(profile.fullName);

Sending SMS

What about sending a SMS? All you have to do is to create an instance of the SmsSender class:

import 'package:sms/sms.dart';

void main() {
  SmsSender sender = new SmsSender();
  String address = someAddress();
  ...
  sender.sendSms(new SmsMessage(address, 'Hello flutter!'));
}

To be notified when the message is sent and/or delivered, you must add a listener to your message:

import 'package:sms/sms.dart';

void main() {
  SmsSender sender = new SmsSender();
  String address = someAddress();
  ...
  SmsMessage message = new SmsMessage(address, 'Hello flutter!');
  message.onStateChanged.listen((state) {
    if (state == SmsMessageState.Sent) {
      print("SMS is sent!");
    } else if (state == SmsMessageState.Delivered) {
      print("SMS is delivered!");
    }
  });
  sender.sendSms(message);
}

Some times it is useful to be notified of delivered messages regardless of the message. To do that you must subscribe to the onSmsDelivered of the SmsSender class instance:

void main() {
...
SmsSender sender = new SmsSender();
sender.onSmsDelivered.listen((SmsMessage message){
  print('${message.address} received your message.');
}));
}

You can also send with another SimCard:

void main() {
SimCardsProvider provider = new SimCardsProvider();
SimCard card = await provider.getSimCards()[0];
SmsSender sender = new SmsSender();
SmsMessage message = new SmsMessage("address", "message");
sender.sendSMS(message, simCard: card);
}

Note: Using the onSmsDelivered from the SmsSender will only notify to listeners of messages that has been sent through SmsSender.send().

Receiving SMS

If you want to be notified for incoming new messages you must subscribe to an instance of the SmsReceiver class:

import 'package:sms/sms.dart';

void main() {
  SmsReceiver receiver = new SmsReceiver();
  receiver.onSmsReceived.listen((SmsMessage msg) => print(msg.body));
}

Roadmap

  • [x] SMS Receiver
  • [x] SMS Sender
  • [x] SMS Delivery
  • [x] SMS Query
  • [x] SMS Thread
  • [ ] MMS Receiver
  • [ ] MMS Sender
  • [ ] MMS Delivery
  • [ ] MMS Query
  • [ ] Multi Sim Card
  • [x] Contact
  • [x] Contact Photo (full size, thumbnail)
  • [x] User profile (basic info)

Contributors

App logo

Designed and created by Imrul kayes

Contributions

Any contribution is welcome.

カテゴリー

ソースリポジトリ

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