1 | import { Platform } from '@unimodules/core';
|
2 | import ExpoSMS from './ExpoSMS';
|
3 |
|
4 | type SMSResponse = {
|
5 | result: 'unknown' | 'sent' | 'cancelled';
|
6 | };
|
7 |
|
8 | export 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 |
|
19 | export async function isAvailableAsync(): Promise<boolean> {
|
20 | return ExpoSMS.isAvailableAsync();
|
21 | }
|