UNPKG

607 BPlain TextView Raw
1import { Platform } from '@unimodules/core';
2import ExpoSMS from './ExpoSMS';
3
4type SMSResponse = {
5 result: 'unknown' | 'sent' | 'cancelled';
6};
7
8export async function sendSMSAsync(
9 addresses: string | string[],
10 message: string
11): Promise<SMSResponse> {
12 const finalAddresses = Array.isArray(addresses) ? addresses : [addresses];
13 if (!ExpoSMS.sendSMSAsync) {
14 throw new Error(`SMS.sendSMSAsync is not supported on ${Platform.OS}`);
15 }
16 return ExpoSMS.sendSMSAsync(finalAddresses, message);
17}
18
19export async function isAvailableAsync(): Promise<boolean> {
20 return ExpoSMS.isAvailableAsync();
21}