From b85ea70e8c7b0e677cfd82248c03d72f27e82509 Mon Sep 17 00:00:00 2001 From: shinriyo Date: Mon, 31 Aug 2020 21:11:25 +0900 Subject: [PATCH] About Kotlin For Kotlin developer --- packages/firebase_messaging/README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/firebase_messaging/README.md b/packages/firebase_messaging/README.md index 14313e6b489e..a9b36d9fef1f 100644 --- a/packages/firebase_messaging/README.md +++ b/packages/firebase_messaging/README.md @@ -98,6 +98,28 @@ By default background messaging is not enabled. To handle messages in the backgr } ``` +1. If you create project with Kotlin, add an `Application.kt` class to your app in the same directory as your `MainActivity.kt`. This is typically found in `/android/app/src/main/kotlin//`. + + ```kotlin + 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.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.java`, make sure to change `package io.flutter.plugins.firebasemessagingexample;` to your package's identifier. Your package's identifier should be something like `com.domain.myapplication`. ```java