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

Enabling background messagin (cloud messaging), documentation #3279

Closed
amir2202 opened this issue Aug 21, 2020 · 1 comment
Closed

Enabling background messagin (cloud messaging), documentation #3279

amir2202 opened this issue Aug 21, 2020 · 1 comment

Comments

@amir2202
Copy link

amir2202 commented Aug 21, 2020

I have tried to use the background capabilities of firebase_messaging, to allow processing messages when the app is not in the foreground. However this causes problems I followed the instructions as in the screenshot below.

Screenshot (118)
For my project the main package resides within kotlin. Thus the project structure is .../app/src/main ,where there are both kotlin and java folders. The mainactivity resides within the kotlin class, thus when adding an application class, I did this here as instructed, as kotlin and java have interoperability, I simply converted the class to kotlin and it is as follows.

package com.dating
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

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

  override fun registerWith(registry:PluginRegistry) {
    GeneratedPluginRegistrant.registerWith(registry)
  }
}

This however yields the following error
C:\Users\amir2\AndroidStudioProjects\dating\android\app\src\main\kotlin\com\dating\Application.kt: (16, 48): Type mismatch: inferred type is PluginRegistry but FlutterEngine was expected and fails compilation within 3 seconds, I have updated the manifest as instructed as well, and set the name to .Application

After further digging, i even tried to change the structure to java, so no kotlin use now, this didnt change anything as i thought. The example code provided i assume has errors as public final class GeneratedPluginRegistrant { public static void registerWith(@NonNull FlutterEngine flutterEngine) {. The example code provided wants to provide a type of PluginRegistry to a function which takes a FlutterEngine type. This is a mistake in the example provided on the https://pub.dev/packages/firebase_messaging documentation for when enabling background messaging.
I do not know still how to enable this appropriately then.

@amir2202 amir2202 changed the title Enabling background messaging using kotlin Enabling background messaging Aug 21, 2020
@amir2202 amir2202 changed the title Enabling background messaging Enabling background messagin (cloud messaging), documentation Aug 21, 2020
@darshankawar
Copy link

Hi @amir2202,
There's similar open issue describing your case, 1684.
Please follow-up there for updates and any questions.
Closing this as duplicate.

@firebase firebase locked and limited conversation to collaborators Sep 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants