Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request permission notification Flutter

I am trying to show a pop up for requesting notification permission. I have tried using permission_handler package but for notification and bluetooth, it will show no dialog. Is there any other way to show dialog to ask notification permission ?

like image 452
wahyu Avatar asked May 20 '26 22:05

wahyu


1 Answers

Using permission_handler package, the following code will pop up a dialog requesting the user for notification permission:

Future<void> requestNotificationPermissions() async {
   final PermissionStatus status = await Permission.notification.request();
   if (status.isGranted) {
      // Notification permissions granted
   } else if (status.isDenied) {
      // Notification permissions denied
   } else if (status.isPermanentlyDenied) {
      // Notification permissions permanently denied, open app settings
      await openAppSettings();
   }
}

You may call the function inside the main function or anywhere you see fit.

like image 179
Aalem Avatar answered May 22 '26 10:05

Aalem