Capacitor SMS plugin with support for Android
Branch: master
Clone or download
Michael Oberwasserlechner
Latest commit 873b64d Feb 6, 2019

README.md

Capacitor SMS plugin

npm npm Twitter Follow Donate

This is plugin for sending short messages using the devices features.

Installation

npm i @byteowls/capacitor-sms

Configuration

This example shows the common process of configuring this plugin.

Although it was taken from a Angular 6 application, it should work in other frameworks as well.

Register plugin

Find the init component of your app, which is in Angular app.component.ts and register this plugin by

import {registerWebPlugin} from "@capacitor/core";
import {SmsManager} from '@byteowls/capacitor-sms';

@Component()
export class AppComponent implements OnInit {

    ngOnInit() {
        console.log("Register custom capacitor plugins");
        registerWebPlugin(SmsManager);
        // other stuff
    }
}

Use it

    Plugins.SmsManager.hasPermission({
        android: {
          openSmsApp: false
        }
    }).then(() => {
        for (const m of recipients) {
            Plugins.SmsManager.send({
                numbers: [m.number],
                text: [m.text],
                android: {
                    openSmsApp: false
                }
            }).then(() => {
                console.log("Successfully sent!");
            }).catch(reason => {
                console.log("Failed to send! Reason: " + reason.message);
            });
        }
    }).catch(reason => {
        console.log("No permssions given!");
    });

Platform: Android

Register the plugin in com.companyname.appname.MainActivity#onCreate

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        List<Class<? extends Plugin>> additionalPlugins = new ArrayList<>();
        // Additional plugins you've installed go here
        // Ex: additionalPlugins.add(TotallyAwesomePlugin.class);
        additionalPlugins.add(SmsManagerPlugin.class);

        // Initializes the Bridge
        this.init(savedInstanceState, additionalPlugins);
    }

Platform: iOS

  • Not supported yet

Platform: Web/PWA

  • Not supported.

Platform: Electron

  • Not supported.

Contribute

Fix a bug or create a new feature

Please do not mix more than one issue in a feature branch. Each feature/bugfix should have its own branch and its own Pull Request (PR).

  1. Create a issue and describe what you want to do at Issue Tracker
  2. Create your feature branch (git checkout -b feature/my-feature or git checkout -b bugfix/my-bugfix)
  3. Test your changes to the best of your ability.
  4. Commit your changes (git commit -m 'Describe feature or bug')
  5. Push to the branch (git push origin feature/my-feature)
  6. Create a Github pull request

Code Style

This repo includes a .editorconfig file, which your IDE should pickup automatically.

If not please use the sun coding convention. Please do not use tabs at all!

Try to change only parts your feature or bugfix requires.

License

MIT. Please see LICENSE.

BYTEOWLS Software & Consulting

This plugin is powered by BYTEOWLS Software & Consulting and was build for Team Conductor - Next generation club management platform.