FLUTTER ECOSYSTEM

shinewanna/BackgroundSmsPlugin

shinewanna/BackgroundSmsPlugin open-source repository details.

BackgroundSmsPlugin 專案封面
Stars
12
Forks
29
最近推送(UTC)
2023年12月6日
專案狀態
未封存
Shine Wanna GitHub avatar
GITHUB User

Shine Wanna ↗

Frontend Engineer

語言DartJavaRubySwiftObjective-C

此儲存庫發佈的套件

使用的依賴

依賴清單 2 項
  • flutter{"sdk":"flutter"}
  • flutter_test開發依賴{"sdk":"flutter"}

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

展開 / 收合專案 README

Background SMS

This is an SMS library for flutter. You can send SMS from foreground, background, and headless.

It only support Android for now.

Installation and Usage

Add background_sms to the dependencies list of the pubspec.yaml file as follow:

dependencies:
  flutter:
    sdk: flutter

  background_sms: ^0.0.1

Then run the command flutter packages get on the console.

First add permission to send sms in AndroidManifest.xml.

<uses-permission android:name="android.permission.SEND_SMS" />

Then request permission for send sms.Use Permission Handler or something other.

Import

import 'package:background_sms/background_sms.dart';

Simply send sms with default sim.

  String result = await BackgroundSms.sendMessage(
     phoneNumber: "09xxxxxxxxx", message: "Message");
    if (result == SmsStatus.sent) {
      print("Sent");
    } else {
      print("Failed");
    }

Send with custom sim slot 1 for sim1, 2 for sim2 and so on.

  String result = await BackgroundSms.sendMessage(
     phoneNumber: "09xxxxxxxxx", message: "Message", simSlot: 1);
    if (result == SmsStatus.sent) {
      print("Sent");
    } else {
      print("Failed");
    }

You can check Custom Sim Slot is support from Native Android.

  bool result = await BackgroundSms.isSupportCustomSim;
    if (result) {
      print("Support Custom Sim Slot");
        String result = await BackgroundSms.sendMessage(
        phoneNumber: "09xxxxxxxxx", message: "Message", simSlot: 1);
        if (result == SmsStatus.sent) {
          print("Sent");
        } else {
          print("Failed");
        }
    } else {
      print("Not Support Custom Sim Slot");
        String result = await BackgroundSms.sendMessage(
        phoneNumber: "09xxxxxxxxx", message: "Message");
        if (result == SmsStatus.sent) {
          print("Sent");
        } else {
          print("Failed");
        }
    }

Platform Detail

Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git Framework • revision 77d935af4d (2 months ago) • 2021-12-16 08:37:33 -0800 Engine • revision 890a5fca2e Tools • Dart 2.15.1

Created by

Shine Wanna