From ed24cc542b70f9d783345182d1042a02c4c80ae4 Mon Sep 17 00:00:00 2001 From: BshrEldebuch <38144217+BshrEldebuch@users.noreply.github.com> Date: Thu, 3 Sep 2020 19:17:08 +0300 Subject: [PATCH 1/3] Update README.md --- packages/firebase_messaging/README.md | 40 +++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/packages/firebase_messaging/README.md b/packages/firebase_messaging/README.md index 14313e6b489e..15eabc96c60f 100644 --- a/packages/firebase_messaging/README.md +++ b/packages/firebase_messaging/README.md @@ -73,7 +73,8 @@ By default background messaging is not enabled. To handle messages in the backgr Note: you can find out what the latest version of the plugin is [here ("Cloud Messaging")](https://firebase.google.com/support/release-notes/android#latest_sdk_versions). -1. Add an `Application.java` class to your app in the same directory as your `MainActivity.java`. This is typically found in `<app-name>/android/app/src/main/java/<app-organization-path>/`. +#### Java's support: +2. Add an `Application.java` class to your app in the same directory as your `MainActivity.java`. This is typically found in `<app-name>/android/app/src/main/java/<app-organization-path>/`. ```java package io.flutter.plugins.firebasemessagingexample; @@ -98,19 +99,48 @@ By default background messaging is not enabled. To handle messages in the backgr } ``` -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`. +3. 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 package com.domain.myapplication; ``` +#### 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>/`. +```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.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")); + } +} +``` +3. In `Application.kt`, 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`. + + ```kotlin + package com.domain.myapplication; + ``` +--- -1. Set name property of application in `AndroidManifest.xml`. This is typically found in `<app-name>/android/app/src/main/`. +4. Set name property of application in `AndroidManifest.xml`. This is typically found in `<app-name>/android/app/src/main/`. ```xml <application android:name=".Application" ...> ``` -1. Define a **TOP-LEVEL** or **STATIC** function to handle background messages +5. Define a **TOP-LEVEL** or **STATIC** function to handle background messages ```dart Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) async { @@ -131,7 +161,7 @@ By default background messaging is not enabled. To handle messages in the backgr Note: the protocol of `data` and `notification` are in line with the fields defined by a [RemoteMessage](https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/RemoteMessage). -1. Set `onBackgroundMessage` handler when calling `configure` +6. Set `onBackgroundMessage` handler when calling `configure` ```dart _firebaseMessaging.configure( From 39a9dbd766e9915397e6de30f39fa7fd268233ce Mon Sep 17 00:00:00 2001 From: BshrEldebuch <38144217+BshrEldebuch@users.noreply.github.com> Date: Thu, 3 Sep 2020 19:26:44 +0300 Subject: [PATCH 2/3] Update CHANGELOG.md Add Kotling support in README.md. --- packages/firebase_messaging/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/firebase_messaging/CHANGELOG.md b/packages/firebase_messaging/CHANGELOG.md index 0ab9e24a0793..46e24199b3f0 100644 --- a/packages/firebase_messaging/CHANGELOG.md +++ b/packages/firebase_messaging/CHANGELOG.md @@ -1,3 +1,6 @@ +## 7.0.1 +* Add Kotling support in README.md. + ## 7.0.0 * Depend on `firebase_core` and migrate plugin to use `firebase_core` native SDK versioning features; From d763b93a817d1724ff823a5ef370790bf7de1cef Mon Sep 17 00:00:00 2001 From: BshrEldebuch <38144217+BshrEldebuch@users.noreply.github.com> Date: Thu, 3 Sep 2020 20:16:37 +0300 Subject: [PATCH 3/3] Update CHANGELOG.md --- packages/firebase_messaging/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firebase_messaging/CHANGELOG.md b/packages/firebase_messaging/CHANGELOG.md index 46e24199b3f0..606ae68aefbf 100644 --- a/packages/firebase_messaging/CHANGELOG.md +++ b/packages/firebase_messaging/CHANGELOG.md @@ -1,5 +1,5 @@ ## 7.0.1 -* Add Kotling support in README.md. +* Add Kotlin support in README.md. ## 7.0.0