You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Seekers/Helpers/SosService.cs

33 lines
969 B

6 months ago
using Justice.Helpers;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Justice.Services
{
public class SosService
{
public async Task SendSosAlertAsync(List<string> recipients)
{
try
{
// Fetch location and address
(double latitude, double longitude, string address) = await GeolocationHelper.GetLocationAsync();
6 months ago
// Prepare the SOS message
string message = $"SOS Alert! I need help. My location:\n" +
$"Latitude: {latitude}, Longitude: {longitude}\n" +
$"Address: {address}\n\n";
// Send the SMS
await SmsHelper.SendSmsAsync(message, recipients);
}
catch (Exception ex)
{
throw new Exception($"SOS Alert failed: {ex.Message}");
}
}
}
}