flutter_notification_permissions
flutter_notification_permissions copied to clipboard
Wait for user response to requestNotificationPermissions
Would it be possible to wait with Future resolution of requestNotificationPermissions()
until user has granted or denied notification permission?
I have this question as well how can we listen to an update from the user when the permission dialog pops up, how could we know whether permission was granted or denied
@droidluv, I've forked flutter_local_notifications in order to add this functionality, you can use my fork https://github.com/dluksza/flutter_local_notifications
Hey all!
Sorry for taking so long in replying.
Could you try version 0.4.3 and let me know if that fixes the issue?
If not could you please elaborate a little more?
I used 0.4.3, and it still does not seem to wait until user comes back from the setting page.
One workaround that I found is to use flutter's [WidgetsBindingObserver](https://api.flutter.dev/flutter/widgets/WidgetsBindingObserver-class.html)
.
Basically, you can observe app lifecycle changes, and should look for AppLifecycleState.resumed
state. When this state is triggered, that likely means that the user has returned back from 'Setting' page, and you can fetch permission again to see if the value has been updated.
class SomeWidgetState extends State<SomeWidget> {
...
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
Future didChangeAppLifecycleState(AppLifecycleState state) async {
// user coming back from settings page (notification change).
if (state == AppLifecycleState.resumed) {
NotificationPermissions.getNotificationPermissionStatus().then((permission) {
...
});
}
...
}
Any news on this ?