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?
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?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.