flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[firebase_messaging 6.0.1] Onresume and OnLaunch not Working on Android 9.0 Pie (API 28)

Open digarahayu opened this issue 7 years ago • 6 comments

FCM not working onResume and onLaunch on Android 9.0 Pie (API 28) i send payload that contains wrong channel id , there is log that says channel id not set in manifest . when i send payload with correct channel_id there is no notification and log.. here plugin that i use

firebase_messaging: ^6.0.1

flutter sdk stable version

v1.9.1+hotfix.6

here my flutter doctor

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.15 19A602, locale en-ID) [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1) [✓] Xcode - develop for iOS and macOS (Xcode 11.0) [✓] Android Studio (version 3.5) [✓] VS Code (version 1.40.2) [!] Connected device ! No devices available ! Doctor found issues in 1 category.

Here My Application.kt

sample
package com.project.jefri
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.os.Build;
import android.util.Log
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()
    Log.d("TAG", "jefri fernnado");
    this.registerChannel();
    FlutterFirebaseMessagingService.setPluginRegistrant(this)
  }

  override fun registerWith(registry: PluginRegistry) {
    GeneratedPluginRegistrant.registerWith(registry)
  }
  
  private fun registerChannel(){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
      Log.d("TAG", "jefri");
      val name = "FCM HAHAHA";
      val descriptionText = "This is channel notification Hahhaha";
      val importance = NotificationManager.IMPORTANCE_DEFAULT
      val mChannel = NotificationChannel("fcm_myproject_channel", name, importance)
      mChannel.description = descriptionText
      val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
      notificationManager.createNotificationChannel(mChannel)
    }
  }
}

I add meta data in my manifest <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="fcm_myproject_channel"/>

digarahayu avatar Nov 28 '19 05:11 digarahayu

up

digarahayu avatar Dec 03 '19 08:12 digarahayu

Did you add click_action?

marinat avatar Dec 05 '19 15:12 marinat

Did you add click_action?

Yes i send payload include click_action on object data and object notification...

You get same problem in 9.0 ??

digarahayu17 avatar Dec 17 '19 15:12 digarahayu17

I added click_action and all works

marinat avatar Dec 17 '19 16:12 marinat

I added click_action and all works

Can you show me what parameter you send for notification Could you share how your manifest.xml and Application.kt

Cause it's already 20 days and i still stuck on this issue even i update flutter problem still not solved

digarahayu17 avatar Dec 17 '19 16:12 digarahayu17

Hey all 👋

As part of our roadmap (#2582) we've just shipped a complete rework of the firebase_messaging plugin that aims to solve this and many other issues.

If you can, please try out the dev release (see the migration guide for upgrading and for changes) and if you have any feedback then join in the discussion here.

Given the scope of the rework I'm going to go ahead and close this issue in favor of trying out the latest plugin.

Thanks everyone.

Salakar avatar Nov 05 '20 09:11 Salakar