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

[firebase_messaging] No documentation for Android v2 embedding backgroundMessage handler #1775

Closed
VictorUvarov opened this issue Jan 8, 2020 · 13 comments
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: messaging type: documentation Improvements or additions to documentation

Comments

@VictorUvarov
Copy link

Describe the bug
Currently the documentation does NOT support the new Flutter Android v2 embedding that came along with flutter 1.12.13. The function GeneratedPluginRegistrant.registerWith(registry); no longer accepts a io.flutter.plugin.common.PluginRegistry object, but a io.flutter.embedding.engine.FlutterEngine object.

Current code in documentation:

 import io.flutter.app.FlutterApplication;
 import io.flutter.plugin.common.PluginRegistry;
 import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
 import io.flutter.plugins.GeneratedPluginRegistrant;
 import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;

 public class Application extends FlutterApplication implements PluginRegistrantCallback {
   @Override
   public void onCreate() {
     super.onCreate();
     FlutterFirebaseMessagingService.setPluginRegistrant(this);
   }

   @Override
   public void registerWith(PluginRegistry registry) {
     GeneratedPluginRegistrant.registerWith(registry);
   }
 }

Newer code attempt with error:

import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;

public class Application extends FlutterApplication implements PluginRegistry.PluginRegistrantCallback {
    @Override
    public void onCreate() {
        super.onCreate();
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
    }

    @Override
    public void registerWith(PluginRegistry registry) {
        GeneratedPluginRegistrant.registerWith(registry); // ERROR: Expects io.flutter.embedding.engine.FlutterEngine
    }
}

To Reproduce
Steps to reproduce the behavior:

  1. Run flutter create -a java example
  2. Follow firebase_messaging background messaging instructions
  3. Notice GeneratedPluginRegistrant.registerWith(registry) no longer expects a PluginRegistry type
@VictorUvarov VictorUvarov added the type: bug Something isn't working label Jan 8, 2020
@iapicca iapicca added type: documentation Improvements or additions to documentation and removed type: bug Something isn't working labels Jan 8, 2020
@stoppiNeobiz
Copy link

any solution for this error?

@sgehrman
Copy link

same issue

@gakubhat
Copy link

Solved it with following:
app/src/build.gradle
add the following:
implementation "com.google.firebase:firebase-messaging:20.1.0"
Application.kt

import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService

class Application : FlutterApplication(), PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate()
        FlutterFirebaseMessagingService.setPluginRegistrant(this)
    }

    override fun registerWith(registry: PluginRegistry?) {
        registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin");
    }


}

@woprandi
Copy link

That would be better to get an official fix and not have to do a workaround with potential side effect

@woprandi
Copy link

I have another issue with the @gakubhat workaround (#116)
I followed this workaround : https://www.djamware.com/post/5e4b26e26cdeb308204b427f/flutter-tutorial-firebase-cloud-messaging-fcm-push-notification

Frustrating to have so many issues on a important plugin...

@iapicca iapicca added the impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) label Feb 28, 2020
@Zazo032
Copy link
Contributor

Zazo032 commented May 15, 2020

@Ehesp hi, is there any ETA for solving this?

@FabulousGee
Copy link

This issue has been opened about half a year ago and still not under real investigation? C'mon guys, this is a real show stopper, especially for newbies that want to get into this stuff...

Just set up a new, standard flutter project and follow the current documentation. It won't work...

@kroikie
Copy link
Collaborator

kroikie commented Jul 29, 2020

@ALL Sorry about the delay here, we are currently working on updating the messaging plugin, the documentation will be updated according to those final updates. We should have more on this very soon.

@videjunior
Copy link

É só você usar o PluginRegistry.PluginRegistrantCallback dessa forma:

class FirebaseCloudMessagingPluginRegistrant {
    companion object {
        fun registerWith(registry: PluginRegistry) {
            if (alreadyRegisteredWith(registry)) {
                return;
            }
            FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
        }

        fun alreadyRegisteredWith(registry: PluginRegistry): Boolean {
            val key = FirebaseCloudMessagingPluginRegistrant::class.java.name
            if (registry.hasPlugin(key)) {
                return true
            }
            registry.registrarFor(key)
            return false
        }
    }
}
class MainActivity : FlutterActivity(), PluginRegistry.PluginRegistrantCallback {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        FlutterFirebaseMessagingService.setPluginRegistrant(this)
    }

    override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine)
    }

    override fun registerWith(registry: PluginRegistry?) {
        registry?.let { FirebaseCloudMessagingPluginRegistrant.registerWith(it) }
    }
}

Funciona normalmente o "backgroundMessage handler" no meu projeto já modificado para embedding V2.

@josh-burton
Copy link
Contributor

I'm a bit confused about which plugins need to be manually registered in the registerWith method.

Is it any plugin that we are using in the background, or is it plugins that haven't yet updated to the v2 embedding?

@pangj
Copy link

pangj commented Oct 24, 2020

Has this issue be resolved now, anybody knows? It is really important plugin for the Flutter framework.

@LasseRosenow
Copy link

LasseRosenow commented Oct 24, 2020

It will be resolved "very very soon", when version 8.0.0 will be released.

@Salakar
Copy link
Member

Salakar commented Nov 5, 2020

Hey all 👋

As part of our roadmap (#2582) we've just shipped a complete rework of the firebase_messaging plugin that aims to solve this and many other issues. Specifically v2 embedding is now supported and requires no documentation/manual steps unless you still need to use v1 embedding.

If you can, please try out the dev release (see the migration guide for upgrading and for changes) and if you have any feedback then join in the discussion here.

Given the scope of the rework I'm going to go ahead and close this issue in favor of trying out the latest plugin.

Thanks everyone.

@Salakar Salakar closed this as completed Nov 5, 2020
@firebase firebase locked and limited conversation to collaborators Dec 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: messaging type: documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests