Open a system standard interface, which lets the user compose and send SMS messages.(iMessage etc)
npm install @lowkey/react-native-open-sms
or
yarn add @lowkey/react-native-open-sms
Install pods
npx pod-install
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;
}
});
};
Prop | Type | Description | Required |
---|---|---|---|
body | String | Message Text | false |
recipients | string[] | Message recipients | true |
Action types returned when promise is resolved
Type | Description |
---|---|
OpenSms.Types.Sent | Message was sent |
OpenSms.Types.Cancelled | User canceled message sending |
OpenSms.Types.Failed | Message sending failed |
OpenSms.Types.NotSupported | Message sending is not supported (iOS simulator) |
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT