Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SMS function to Alarm.js #30

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions screens/Alarm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useState } from 'react';
import { View, Text, TouchableOpacity } from 'react-native';
import DateTimePickerModal from 'react-native-modal-datetime-picker';
// eslint-disable-next-line import/no-extraneous-dependencies
import * as SMS from 'expo-sms';
import { textStyles, styles } from '../styles/styles';

function AlarmClock() {
Expand Down Expand Up @@ -28,6 +30,7 @@ function AlarmClock() {
alert('Wake up!');
setIsAlarmSet(false);
setCountdown('');
// sendAlarmNotification();--> Need to implement feature in settings that takes phone number input
}, timeUntilAlarm);

// Start updating the countdown every second
Expand All @@ -47,6 +50,12 @@ function AlarmClock() {

hideDatePicker();
};
const sendAlarmNotification = async (phoneNumber) => {
const isAvailable = await SMS.isAvailableAsync();
if (isAvailable) {
await SMS.sendSMSAsync(phoneNumber, 'Alarm missed! Wake up!');
}
};

return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
Expand Down