Closed
Description
For new projects with Kotlin support, the project only contains MainActivity.kt
and not Java
, and as for now, docs doesn't support it.
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"));
}
}
- 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 likecom.domain.myapplication
.
package com.domain.myapplication;