Reputation: 664
I am using the Flutter notification_permissions package.
I can retrieve the device notification permission status asynchronously by calling:
PermissionStatus p = await NotificationPermissions.getNotificationPermissionStatus()
However, I do not want to do this just once. I want to listen to the notification status as a stream, so that when it changes I can respond accordingly in my UI.
I tried the following:
NotificationPermissions.getNotificationPermissionStatus().asStream().listen((PermissionStatus s) {
print('Notification permissions: $s');
}
However, this stream does not emit events when I change the notification settings on the device.
How can I achieve this?
Upvotes: 3
Views: 3152
Reputation: 664
I have achieved my desired functionality by creating a stateful widget that listens to the AppLifecycleState. I then call my async function whenever the app resumes to check the status of notification settings.
More info here: Flutter: Update Widgets On Resume?
Upvotes: 4