Giter Club home page Giter Club logo

capacitor-sms's Introduction

Capacitor SMS plugin

Plugin for sending short messages using the device's SMS app.

Installation

For Capacitor v3

npm i @byteowls/capacitor-sms
npx cap sync

For Capacitor v2 use 2.0.0

npm i @byteowls/[email protected]
npx cap sync

Versions

Plugin For Capacitor Docs Notes
3.x 3.x.x README Breaking changes see Changelog. XCode 12.0 needs this version
2.x 2.x.x README Breaking changes see Changelog. XCode 11.4 needs this version
1.x 1.x.x README

Sponsors

I would like to especially thank some people and companies for supporting my work on this plugin and therefore improving it for everybody.

Maintainers

Maintainer GitHub Consulting
Michael Oberwasserlechner moberwasserlechner https://byteowls.com

Configuration

Starting with version 3.0.0, the plugin is registered automatically on all platforms.

This plugin always uses the default sms app.

Use it

import {Component, OnInit} from '@angular/core';
import {SmsManager} from "@byteowls/capacitor-sms";
import {Device, DeviceInfo} from "@capacitor/device";


@Component({
    template: "<button mat-raised-button color='primary' (click)='sendSms()'>Send SMS now!</button>"
})
export class SmsExampleComponent implements OnInit {

    iosOrAndroid: boolean;

    async ngOnInit() {
        const info: DeviceInfo = await Device.getInfo();
        this.iosOrAndroid = (info.platform === "android" || info.platform === "ios");
    }

    sendSms() {
        const numbers: string[] = ["+43 123 123123123", "+43 4564 56456456"];
        SmsManager.send({
            numbers: numbers,
            text: "This is a example SMS",
        }).then(() => {
            // success
        }).catch(error => {
            console.error(error);
        });
    }
}

Error Codes

  • SEND_CANCELLED ... User cancelled or closed the SMS app. (ios only)
  • ERR_SEND_FAILED ... The SMS app returned that sending the message to the recipients failed. (ios only)
  • ERR_SEND_UNKNOWN_STATE ... The SMS app returned a unknown state. There is nothing I can do to clarify the error. (ios only)
  • ERR_PLATFORM_NOT_SUPPORTED ... Sending SMS on the web is not supported.
  • ERR_NO_NUMBERS ... No recipient numbers were retrieved from options. Make sure to deliver only valid numbers, because the whole sending will fail.
  • ERR_NO_TEXT ... No message text was retrieved from options.
  • ERR_SERVICE_NOTFOUND ... The used device can not send SMS.

Platform: Android

Prerequisite: Capacitor Android Docs

Register plugin

On Android the plugin is registered automatically by Capacitor.

Platform: iOS

Register plugin

On iOS the plugin is registered automatically by Capacitor.

Platform: Web/PWA

  • Not supported.

Platform: Electron

  • Not supported.

Contribute

See Contribution Guidelines.

Changelog

See CHANGELOG.

License

MIT. Please see LICENSE.

BYTEOWLS Software & Consulting

This plugin is powered by BYTEOWLS Software & Consulting.

If you need extended support for this project like critical changes or releases ahead of schedule. Feel free to contact us for a consulting offer.

Disclaimer

We have no business relation to Ionic.

capacitor-sms's People

Contributors

chrum avatar moberwasserlechner avatar tartanlegrand 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.