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] Add "Application.kt" for Kotlin support. #3454

Closed
beshr-eldebuch opened this issue Sep 3, 2020 · 3 comments · Fixed by #4012
Closed

[📚] [firebase_messaging] Add "Application.kt" for Kotlin support. #3454

beshr-eldebuch opened this issue Sep 3, 2020 · 3 comments · Fixed by #4012
Labels
good first issue Good for newcomers plugin: messaging type: documentation Improvements or additions to documentation

Comments

@beshr-eldebuch
Copy link

For new projects with Kotlin support, the project only contains MainActivity.kt and not Java, and as for now, docs doesn't support it.
image

I suggest adding the following to GettingStarted.

Kotlin's support.
2. Add an Application.kt class to your app in the same directory as your MainActivity.kt. This is typically found in <app-name>/android/app/src/main/kotlin/<app-organization-path>/ .

package io.flutter.plugins.firebasemessagingexample

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?) {
        io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
    }
}
  1. In Application.kt, make sure to change the package io.flutter.plugins.firebasemessagingexample to your package's identifier. Your package's identifier should be something like com.domain.myapplication.
    package com.domain.myapplication;
@beshr-eldebuch beshr-eldebuch added good first issue Good for newcomers type: documentation Improvements or additions to documentation labels Sep 3, 2020
@beshr-eldebuch beshr-eldebuch changed the title [📚] Add "Application.kt" for Kotlin support [📚] [firebase_messaging] Add "Application.kt" for Kotlin support. Sep 3, 2020
@darshankawar
Copy link

Similar issue 3411

@ripesol
Copy link

ripesol commented Oct 3, 2020

any update on it ?
my project is in final stage to release but only push notification not working for kptlin is stopping me as i can't find any other way to get fcm work with my project.
Kindly suggest how i can use this plugin with my kotlin based project.
thanks

@beshr-eldebuch
Copy link
Author

@ripesol Check out this pull request 3457

@firebase firebase locked and limited conversation to collaborators Dec 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers plugin: messaging type: documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants