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.
32 lines
976 B
32 lines
976 B
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.GetCurrentLocationAsync();
|
|
|
|
|
|
// 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}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|