#3.467 — push android
Published in
1 min readMay 20, 2020
Решил проблему с push background на android.
Для ios надо видимо посмотреть https://firebase.google.com/docs/cloud-messaging/ios/send-image или параметры сообещния проверить.
MainActivity.kt
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
flutterEngine.plugins.add(FirebaseMessagingPlugin())
GeneratedPluginRegistrant.registerWith(flutterEngine);
...
Application.kt
class Application : FlutterApplication(), PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
FlutterFirebaseMessagingService.setPluginRegistrant(this)
}override fun registerWith(registry: PluginRegistry) {
FirebaseCloudMessagingPluginRegistrant.registerWith(registry)
// registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin");
}
}
FirebaseCloudMessagingPluginRegistrant.kt
package app.meows.meowsimport io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPluginobject FirebaseCloudMessagingPluginRegistrant {
fun registerWith(registry: PluginRegistry?) {
if (alreadyRegisteredWith(registry)) {
return
}
FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
}private fun alreadyRegisteredWith(registry: PluginRegistry?): Boolean {
val key: String? = FirebaseCloudMessagingPluginRegistrant::class.java.canonicalName
if (registry?.hasPlugin(key)!!) {
return true
}
registry.registrarFor(key)
return false
}
}
Подписка на телеграмм: https://t.me/It_challenge
20.05.2020