Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_sendSMS = async () => {
const isAvailable = await SMS.isAvailableAsync();
if (!isAvailable) {
this.setState({
error: 'SMS functionality is not available on this device!',
});
setTimeout(() => this.setState({ error: undefined }), 10000);
return;
}
try {
if (this.state.message) {
const { result } = await SMS.sendSMSAsync(
this.state.phoneNumbers,
this.state.message
);
this.setState({ phoneNumbers: [], message: undefined, result });
setTimeout(() => this.setState({ result: undefined }), 5000);
}
} catch (e) {
this.setState({ error: e.message });
setTimeout(() => this.setState({ error: undefined }), 10000);
}
}
return SMS.isAvailableAsync().then(isAvailable => {
if (!isAvailable) {
throw new Error('SMS not available')
}
return SMS.sendSMSAsync(phonenos, body || '')
})
}