Update Sync
This commit is contained in:
commit
4777571334
30 files changed
+9627
No files matched your search
@@ -0,0 +1,64 @@
|
||||
import React, { useState } from 'react';
|
||||
import { View, Text, StyleSheet, Button } from 'react-native';
|
||||
import * as SMS from 'expo-sms';
|
||||
|
||||
const SendSMS = () => {
|
||||
const [message, setMessage] = useState('Levi McLean\n123 Main St\nLondon, ON\n(555) 555-5555\naidanmclean111@gmail.com');
|
||||
|
||||
const sendMessageWithSMS = async () => {
|
||||
const isAvailable = await SMS.isAvailableAsync();
|
||||
if (isAvailable) {
|
||||
const recipients = ['+15195351398']; // Replace with the recipient's phone number
|
||||
const options = {
|
||||
recipients: recipients,
|
||||
message: message,
|
||||
};
|
||||
await SMS.sendSMSAsync(options.recipients, options.message)
|
||||
.then((result) => {
|
||||
if (result.result === 'sent') {
|
||||
Alert.alert('SMS sent successfully');
|
||||
} else {
|
||||
Alert.alert('Failed to send SMS');
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
Alert.alert('Error sending SMS');
|
||||
});
|
||||
} else {
|
||||
Alert.alert('SMS is not available on this device');
|
||||
};
|
||||
};
|
||||
|
||||
const onChangeHandler = (value) => {
|
||||
setMessage(value);
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={styles.form}>
|
||||
<Text style={styles.label}>You are going to send the following info:</Text>
|
||||
<Text style={styles.messageInfo}>{message}</Text>
|
||||
|
||||
<Button title="Send via SMS" onPress={sendMessageWithSMS} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
form: {
|
||||
padding: 30,
|
||||
marginTop: 60,
|
||||
},
|
||||
label: {
|
||||
fontSize: 18,
|
||||
marginBottom: 30,
|
||||
textAlign: 'center',
|
||||
},
|
||||
messageInfo: {
|
||||
fontSize: 16,
|
||||
marginBottom: 15,
|
||||
textAlign: 'center',
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
});
|
||||
|
||||
export default SendSMS;
|
||||
Reference in new issue
Block a user