flutter_notification_permissions icon indicating copy to clipboard operation
flutter_notification_permissions copied to clipboard

MissingPluginException

Open mikeesouth opened this issue 4 years ago • 6 comments

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.

mikeesouth avatar May 07 '20 09:05 mikeesouth

I will look into this

So, I can replicate this issue if I create a new project with obj-c, correct @mikeesouth ?

Vanethos avatar May 17 '20 11:05 Vanethos

@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 avatar May 17 '20 20:05 mikeesouth

@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.

Vanethos avatar Jun 06 '20 11:06 Vanethos

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

mltbnz avatar May 04 '21 11:05 mltbnz

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)

stephanie-finch avatar Jun 12 '21 00:06 stephanie-finch

Did you guys figure it out?

faroukcharkas avatar May 26 '22 03:05 faroukcharkas