19 lines
660 B
Dart
19 lines
660 B
Dart
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
Future<bool> requestNotificationPermission() async {
|
|
final status = await Permission.notification.request();
|
|
|
|
if (status.isGranted) {
|
|
print("Notification permission granted!");
|
|
} else if (status.isDenied) {
|
|
print("Notification permission denied.");
|
|
// Optionally show a dialog or a snackbar explaining the importance of the permission
|
|
} else if (status.isPermanentlyDenied) {
|
|
print("Notification permission permanently denied.");
|
|
// You can redirect the user to the app settings to change the permission manually
|
|
openAppSettings();
|
|
}
|
|
|
|
return status.isGranted;
|
|
}
|