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 ?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With