import 'package:flutter/foundation.dart'; import 'package:http/http.dart' as http; class PushNotificationsService { static const _url = 'https://physigo.vercel.app/api/push-notification'; static void sendFriendRequestNotification(String userId, String name, String surname) { const title = "Friend Request"; final body = "$name $surname wants to be your friend"; _sendPushNotification(userId, title, body); } static void sendChallengeLocationRequestNotification(String userId, String name, String surname) { const title = "Shared Challenge location request"; final body = "$name $surname shared their challenge's location with you"; _sendPushNotification(userId, title, body); } static void sendFriendRequestAcceptedNotification(String userId, String name, String surname) { const title = "New Friend"; final body = "$name $surname is now your friend!"; _sendPushNotification(userId, title, body); } static Future _sendPushNotification(String userId, String title, String body) async { try { await http.post(Uri.parse('$_url?user_id=$userId&title=$title&body=$body')); } catch (error) { // We don't care if sending the notification fails if (kDebugMode) { debugPrint(error.toString()); } } } }