0.1.1 • Published 3 years ago

@lowkey/react-native-open-sms v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-native-open-sms

Open a system standard interface, which lets the user compose and send SMS messages.(iMessage etc)

EB4B4044-6A97-43D3-8253-80E0A94A5AA8

Installation

npm install @lowkey/react-native-open-sms

or

yarn add @lowkey/react-native-open-sms

Install pods

npx pod-install

Usage

import OpenSms from '@lowkey/react-native-open-sms';

// ...

const openComposer = () => {
    OpenSms.displaySMSComposerSheet({
      body: 'Hello my dear friend!',
      recipients: ['1234567890'],
    }).then((result: string) => {
      switch (result) {
        case OpenSms.Types.Sent:
          console.log('Message was sent!');
          break;
        case OpenSms.Types.Cancelled:
          console.log('Sending was cancelled!');
          break;
        case OpenSms.Types.Failed:
          console.log('Sending failed');
          break;
        case OpenSms.Types.NotSupported:
          console.log('Sending is not supported');
          break;
        default:
          console.log('Error occupied', result);
          break;
      }
    });
  };

Props

PropTypeDescriptionRequired
bodyStringMessage Textfalse
recipientsstring[]Message recipientstrue

Types

Action types returned when promise is resolved

TypeDescription
OpenSms.Types.SentMessage was sent
OpenSms.Types.CancelledUser canceled message sending
OpenSms.Types.FailedMessage sending failed
OpenSms.Types.NotSupportedMessage sending is not supported (iOS simulator)

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

0.1.1

3 years ago

0.1.0

3 years ago