Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingPluginException(No implementation found for method createNewNotification on channel awesome_notifications) #18

Closed
thesmalleyes opened this issue Oct 22, 2020 · 10 comments

Comments

@thesmalleyes
Copy link

Hi, I followed your instruction about how to use this package.
So, I added initialize channel in my main.dart
Then I call create notification from the app, it's work
But, when i call it from background, push notification, i got the error mesage

Unable to handle incoming background message.
I/flutter (20190): MissingPluginException(No implementation found for method createNewNotification on channel awesome_notifications)

What's wrong?

@rafaelsetragni
Copy link
Owner

How are you calling it from background? Paste here a code example

@thesmalleyes
Copy link
Author

So I have my backgroundMessageHandler in main.dart
I have created channel basic_test in main.dart before runApp.

Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) async {
  if (message.containsKey('data')) {
    // Handle data message
    final dynamic data = message['data'];
    String title = data['nt']??data['title'];
    String body = data['nm']??data['body'];
    String imageUrl = data['wzrk_bp']??'';
    return title.isEmpty? null : showNotification(title, body, imageUrl);
  }
}

When onBackground triggered, i show notification by call showNotification() method above.
show_notifications.dart

class ShowNotifications{
//other method
showNotification(String title, String body, String image)async{
  await AwesomeNotifications().createNotification(
      content: NotificationContent(
          id: id,
          channelKey: 'basic_test',
          title: title',
          bigPicture:
              'https://i0.wp.com/www.jornadageek.com.br/wp-content/uploads/2018/06/Looney-tunes.png?resize=696%2C398&ssl=1',
          notificationLayout: NotificationLayout.BigPicture,
          payload: {'uuid': 'uuid-test'}));
}
}

Whenever I called showNotification from any screen, the notif is show. But, when onbackground notification triggered, the error happened.

Unable to handle incoming background message.
I/flutter (20190): MissingPluginException(No implementation found for method createNewNotification on channel awesome_notifications)

@rafaelsetragni
Copy link
Owner

rafaelsetragni commented Oct 22, 2020

It seems like the plugin is not beeing initialized by Flutter on your background fetch. So there is no native handle registred to receive your background call.

Can you share with me your project on github to me reproduce this error?

Edit:
Are you using background_fetch plugin?

@thesmalleyes
Copy link
Author

thesmalleyes commented Oct 24, 2020

I created a mini example of how I used the package in https://github.com/bayuramadeza/Awesome-Notification-FCM,
I think this package should have something like :
FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin")) to add in Application.kt to handle this error.

Nope, I didn't use background_fetch

@rafaelsetragni
Copy link
Owner

rafaelsetragni commented Oct 26, 2020

Im fixing your source.

First, you SHOULD NOT USE firebase messaging classes on your project directly. You should strictly follow the steps to How to show Local Notifications and, to use firebase messaging which is optional, you should follow the steps to Using Firebase Services (Optional).

Do not do anything else than what is indicate on the documentation. All the firebase class to send FCM was already implemented, managed and installed inside the Awesome Notifications plugin. You dont need to do anything else.

Also, you must respect the structure specified in How to send Push Notifications using Firebase Cloud Messaging (FCM) and do not send push notifications with "notification" field, only "data".

Edit: Example DONE
https://github.com/bayuramadeza/Awesome-Notification-FCM

@thesmalleyes
Copy link
Author

thesmalleyes commented Oct 27, 2020

Thanks!! It works now.
But, I still have some questions.

  1. Can the notification show up like heads-up notification, like image below?

Screen Shot 2020-10-27 at 13 56 45

2. Can the notification handle onMessage notification like FCM? So it doesn't need to show in background, instead it pop in app screen.? 3. The problem I got is the marketing tools use their own data to handle notification, the notification structure is {"data" ; {"title" : title, "body": body, ....}}, So, i can't customize it like the the structure specified in the package notification structure

@rafaelsetragni
Copy link
Owner

  1. Sure. You can manipulate the entire notification to show as exactly as this example, changing title, body, showWhen, activating BigPicture layout with largeIcon and, for last, including the two actionButtons "Reply" and "Archive".

And also you can control if your notification will automatically shows on foreground or background, using the variables displayOnForeground and displayOnBackground. Its all up to you.

  1. onMessage event is equivalent to displayedStream stream. You just need to listen this stream, as you do on actionStream. Youll always receive the event on displayedStream, even when your app is terminate. Sometimes the streams could not be delivered on exactly time when they happen, but they will be delivered as soon as possible to your Flutter app.

You can check all those combinations on our Notification Life Cycle and Flutter Streams topics.

Also, i do recommend you to watch this video about Dart Streams:

Dart Streams

@rafaelsetragni
Copy link
Owner

rafaelsetragni commented Oct 27, 2020

Can i put your example code on our README documentation? This will allows the others to use this example to learn how to use Awesome Notifications and Firebase Cloud Messaging more easly.

And, of course, I want to include your name as thanks for helping the community. Can i?

@thesmalleyes
Copy link
Author

Okay, Thankyou so much for your explanation. I got it,
Sure, You can put my example code in your README documentation. I'm pleasure to heard it

@jenniestrongbow
Copy link

@rafaelsetragni
Hi you mentioned the displayOnBackground option. I did not see it in the documentation. How do I set it? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants