From f866e187aefbbfe911c4d5ba49d0a5613a0e4aaa Mon Sep 17 00:00:00 2001 From: Rafael <1024481@stud.hs-mannheim.de> Date: Fri, 12 Jul 2024 15:08:41 +0200 Subject: [PATCH] Request Notifications Permission required for Android 13 and above --- android/app/src/main/AndroidManifest.xml | 1 + lib/main.dart | 2 ++ lib/services/swipe_stream_service.dart | 2 +- lib/utils/math.dart | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 81d2263..f8d05ad 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ + ()?.requestNotificationsPermission(); const AndroidInitializationSettings initializationSettingsAndroid = AndroidInitializationSettings('@mipmap/ic_launcher'); const InitializationSettings initializationSettings = diff --git a/lib/services/swipe_stream_service.dart b/lib/services/swipe_stream_service.dart index ca0b1be..fedaa7d 100644 --- a/lib/services/swipe_stream_service.dart +++ b/lib/services/swipe_stream_service.dart @@ -50,7 +50,7 @@ class SwipeStreamService { String matchName = await UserService.getUserName(swipeId); const AndroidNotificationDetails androidPlatformChannelSpecifics = AndroidNotificationDetails( - 'my_match_channel_id', 'my_match_channel_name', + 'new_matches_channel_id', 'new_match_info', channelShowBadge: true, visibility: NotificationVisibility.private, importance: Importance.max, diff --git a/lib/utils/math.dart b/lib/utils/math.dart index 9648959..fdf0bb8 100644 --- a/lib/utils/math.dart +++ b/lib/utils/math.dart @@ -45,7 +45,8 @@ String convertDecimalToDMS(double decimalValue, {required bool isLatitude}) { double calculateDistance(double lat1, double lon1, double lat2, double lon2) { const R = 6371; // earth radius in kilometers - // distance between latitudes and longitudes + // Haversine formula to get distance between latitudes and longitudes + // https://en.wikipedia.org/wiki/Haversine_formula final dLat = _degreesToRadians(lat2 - lat1); final dLon = _degreesToRadians(lon2 - lon1);