flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [firebase_messaging 8.0.0-dev.15] after upgrade build android not working anymore

Open digarahayu opened this issue 5 years ago • 1 comments

Hello there, anybody know how to fix my issue after upgrade firebase_message i got error like this

Application.kt: (10, 27): Unresolved reference: firebasemessaging
Application.kt: (16, 5): Unresolved reference: FlutterFirebaseMessagingService
Application.kt: (19, 24): Unresolved reference: firebasemessaging

This is what my Application.kt looks like

package com.wa.wew
import android.os.Build;
import android.util.Log
import android.app.NotificationChannel;
import android.app.NotificationManager;
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()
    this.registerChannel();
    FlutterFirebaseMessagingService.setPluginRegistrant(this);
  } 
  override fun registerWith(registry: PluginRegistry?) {
    io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
  }
  private fun registerChannel(){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
      val name = "FCM Tes";
      val descriptionText = "This is channel notification tes";
      val importance = NotificationManager.IMPORTANCE_DEFAULT
      val mChannel = NotificationChannel("fcm_orangt_channel", name, importance)
      mChannel.description = descriptionText
      val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
      notificationManager.createNotificationChannel(mChannel)
    }
  }
}

when i use old version from firebase_messaging no issue

digarahayu avatar Mar 04 '21 15:03 digarahayu

Hi @digarahayu As mentioned in the migration guide the plugin no longer requires any native workarounds and works out of the box. You need to remove Application.kt and change the AndroidManifest.xml value back to MainActivity. Thank you

markusaksli-nc avatar Mar 04 '21 16:03 markusaksli-nc