flutter_notification_permissions
flutter_notification_permissions copied to clipboard
MissingPluginException
Hi,
I'm getting this exception when running the project on an iOS device (emulator or physical):
Unhandled Exception: MissingPluginException(No implementation found for method getNotificationPermissionStatus on channel notification_permissions)
The implementation works on Android devices. My flutter project is created from an old template (when obj-c was the default for the iOS project) but I have a swift file in the project, I have the use_frameworks!
fix from https://stackoverflow.com/questions/53450817/flutter-type-uiapplication-has-no-member-opensettingsurlstring/53453243#53453243 and I have a requirement on SWIFT 5.0.
I can see that the getNotificationPermissionStatus is handled in the swift file and that the obj-c file wraps the swift logic.
Any idea why I'm getting this error? Ping @Vanethos - if you have any ideas I would really appreciate your feedback.
I will look into this
So, I can replicate this issue if I create a new project with obj-c, correct @mikeesouth ?
@Vanethos thanks for your attention. I'm not sure that you can replicate with just creating an objective-c project. I created my project with obj-c but I have added a swift file since that so I'm not sure where that leaves me, in obj-c or swift.
I got the exception when calling NotificationPermissions.getNotificationPermissionStatus().then(....)
in MyApp.initState() - i.e. before building the MaterialApp widget. But last week I tried moving your code to a button within the app to make it more like your example code and then it worked.
So I guess there could be some logical explanation why I got this exception when calling NotificationPermissions.getNotificationPermissionStatus()
in MyApp.initState(), before building the MaterialApp?
With that in mind - you can go ahead and close this issue.
@mikeesouth I might be wrong, but I think that if you want to access any plugin before the app is initialized, you have to call the following method before runApp
:
WidgetsBinding ensureInitialized()
https://api.flutter.dev/flutter/widgets/WidgetsFlutterBinding/ensureInitialized.html
You only need to call this method if you need the binding to be initialized before calling runApp.
I am facing the same issue when calling requestNotificationPermission()
The app is running since I am already on a detail page.
MissingPluginException (MissingPluginException(No implementation found for method requestNotificationPermissions on channel notification_permissions))
No implementation found for method requestNotificationPermissions on channel notification_permissions
I am also encountering this error on the iOS emulator when the app is already running. Trying to check if permission was granted before showing a prompt.
[VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method getNotificationPermissionStatus on channel notification_permissions)
#0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:156
<asynchronous suspension>
#1 NotificationPermissions.getNotificationPermissionStatus (package:notification_permissions/notification_permissions.dart:23:9)
Did you guys figure it out?