Code Monkey home page Code Monkey logo

backgroundsmsplugin's Introduction

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

backgroundsmsplugin's People

Contributors

shinewanna avatar

Stargazers

AdamMusa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.