Request Notifications Permission required for Android 13 and above

master
Rafael 2024-07-12 15:08:41 +02:00
parent 9ddfb5cfd5
commit f866e187ae
4 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<application <application
android:label="cofounderella" android:label="cofounderella"
android:name="${applicationName}" android:name="${applicationName}"

View File

@ -26,6 +26,8 @@ void main() async {
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin(); FlutterLocalNotificationsPlugin();
flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()?.requestNotificationsPermission();
const AndroidInitializationSettings initializationSettingsAndroid = const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('@mipmap/ic_launcher'); AndroidInitializationSettings('@mipmap/ic_launcher');
const InitializationSettings initializationSettings = const InitializationSettings initializationSettings =

View File

@ -50,7 +50,7 @@ class SwipeStreamService {
String matchName = await UserService.getUserName(swipeId); String matchName = await UserService.getUserName(swipeId);
const AndroidNotificationDetails androidPlatformChannelSpecifics = const AndroidNotificationDetails androidPlatformChannelSpecifics =
AndroidNotificationDetails( AndroidNotificationDetails(
'my_match_channel_id', 'my_match_channel_name', 'new_matches_channel_id', 'new_match_info',
channelShowBadge: true, channelShowBadge: true,
visibility: NotificationVisibility.private, visibility: NotificationVisibility.private,
importance: Importance.max, importance: Importance.max,

View File

@ -45,7 +45,8 @@ String convertDecimalToDMS(double decimalValue, {required bool isLatitude}) {
double calculateDistance(double lat1, double lon1, double lat2, double lon2) { double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
const R = 6371; // earth radius in kilometers 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 dLat = _degreesToRadians(lat2 - lat1);
final dLon = _degreesToRadians(lon2 - lon1); final dLon = _degreesToRadians(lon2 - lon1);