Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[firebase_messaging] <Background push notification handling - no implementation found for method FcmDartService#initialized> #116

Closed
urbanjagodic opened this issue Sep 9, 2019 · 32 comments
Assignees
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: messaging type: bug Something isn't working

Comments

@urbanjagodic
Copy link

urbanjagodic commented Sep 9, 2019

Occurrence of MissingPluginException(No implementation found for method FcmDartService#initialized)

Recently I have updated FCM plugin for flutter to 5.1.5 version that supports
handling of background push notifications. I have followed the instructions
to implement and incorporate it into my application, but handling still fails.
Every time when I try to interact with a push notification on device, from onResume or onLaunch state, plugin fails and I receive this error:

> E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): Failed to handle method call
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): java.lang.IllegalStateException: registrar.activity() must not be null
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at com.apptreesoftware.barcodescan.BarcodeScanPlugin$Companion.registerWith(BarcodeScanPlugin.kt:19)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at com.apptreesoftware.barcodescan.BarcodeScanPlugin.registerWith(Unknown Source:2)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:28)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at example.app.myapp.Application.registerWith(Application.kt:18)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.startBackgroundIsolate(FlutterFirebaseMessagingService.java:164)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.onMethodCall(FirebaseMessagingPlugin.java:133)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at android.app.ActivityThread.main(ActivityThread.java:6863)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
E/MethodChannel#plugins.flutter.io/firebase_messaging(19582): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/flutter (19582): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, registrar.activity() must not be null, null)
E/flutter (19582): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
E/flutter (19582): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
E/flutter (19582): <asynchronous suspension>
E/flutter (19582): #2      FirebaseMessaging.configure (package:firebase_messaging/firebase_messaging.dart:118:16)
E/flutter (19582): #3      PushNotificationReceiver.handleReceivedPushNotification (package:panda/utils/push_notification_receiver.dart:57:26)
E/flutter (19582): #4      _MainNavigationState.build (package:panda/navigation/main_navigation.dart:116:30)
E/flutter (19582): #5      StatefulElement.build (package:flutter/src/widgets/framework.dart:4012:27)
E/flutter (19582): #6      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3924:15)
E/flutter (19582): #7      Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)
E/flutter (19582): #8      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5)
E/flutter (19582): #9      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4053:11)
E/flutter (19582): #10     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5)
E/flutter (19582): #11     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
E/flutter (19582): #12     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
E/flutter (19582): #13     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16)
E/flutter (19582): #14     Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)
E/flutter (19582): #15     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5)
E/flutter (19582): #16     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5)
E/flutter (19582): #17     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
E/flutter (19582): #18     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
E/flutter (19582): #19     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5092:14)
E/flutter (19582): #20     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
E/flutter (19582): #21     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
E/flutter (19582): #22     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5092:14)
E/flutter (19582): #23     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
E/flutter (19582): #24     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
E/flutter (19582): #25     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5092:14)
E/flutter (19582): #26     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
E/flutter (19582): #27     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
E/flutter (19582): #28     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16)
E/flutter (19582): #29     Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)
E/flutter (19582): #30     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5)
E/flutter (19582): #31     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4053:11)
E/flutter (19582): #32     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5)
E/flutter (19582): #33     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
E/flutter (19582): #34     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
E/flutter (19582): #35     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16)
E/flutter (19582): #36     Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)
E/flutter (19582): #37     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5)
E/flutter (19582): #38     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4053:11)
E/flutter (19582): #39     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5)
E/flutter (19582): #40     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
E/flutter (19582): #41     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
E/flutter (19582): #42     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5092:14)
E/flutter (19582): #43     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
E/flutter (19582): #44     Element.updateChild (package:flutter/src/widget
E/flutter (19582): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] **Unhandled Exception: MissingPluginException(No implementation found for method FcmDartService#initialized on channel plugins.flutter.io/firebase_messaging_background)**
E/flutter (19582): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)
E/flutter (19582): <asynchronous suspension>
E/flutter (19582): #1      _fcmSetupBackgroundChannel (package:firebase_messaging/firebase_messaging.dart:50:21)
E/flutter (19582): #2      _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
E/flutter (19582): #3      _fcmSetupBackgroundChannel (package:firebase_messaging/firebase_messaging.dart:23:32)
E/flutter (19582): #4      _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:216:25)
E/flutter (19582): #5      _rootRun (dart:async/zone.dart:1124:13)
E/flutter (19582): #6      _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter (19582): #7      _runZoned (dart:async/zone.dart:1516:10)
E/flutter (19582): #8      runZoned (dart:async/zone.dart:1500:12)
E/flutter (19582): #9      _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:208:5)
E/flutter (19582): #10     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
E/flutter (19582): #11     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
E/flutter (19582): 

Here are my Application.kt and MainActivity kotlin classes:

Application.kt

package example.app.myapp

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) {
    GeneratedPluginRegistrant.registerWith(registry)
  }
}

MainActivity.kt:

package example.app.myapp

import android.os.Bundle

import io.flutter.plugins.GeneratedPluginRegistrant
import android.view.WindowManager.LayoutParams
import io.flutter.app.FlutterFragmentActivity

class MainActivity: FlutterFragmentActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    GeneratedPluginRegistrant.registerWith(this)
    getWindow().addFlags(LayoutParams.FLAG_SECURE)
  }
}
@urbanjagodic urbanjagodic added the type: bug Something isn't working label Sep 9, 2019
@anatter

This comment has been minimized.

@kevmax1

This comment has been minimized.

@mohmdezeldeen

This comment has been minimized.

@divan
Copy link

divan commented Oct 2, 2019

So in the new firebase_messaging version, support for background messages was added. Actually, if you don't add background message handler, it failed to work on Android for me, so I added handler, according to docs:

_fcm.configure(
	...
	onBackgroundMessage: myBackgroundMessageHandler,
	...
)

Now, if you run code with background handler on iOS, it explodes with the error in this issue. So the solution is to set the handler to null for iOS:

_fcm.configure(
	...
	onBackgroundMessage: Platform.isIOS ? null : myBackgroundMessageHandler,
	...
)

This solved the problem for me.

@urbanjagodic
Copy link
Author

So in the new firebase_messaging version, support for background messages was added. Actually, if you don't add background message handler, it failed to work on Android for me, so I added handler, according to docs:

_fcm.configure(
	...
	onBackgroundMessage: myBackgroundMessageHandler,
	...
)

Now, if you run code with background handler on iOS, it explodes with the error in this issue. So the solution is to set the handler to null for iOS:

_fcm.configure(
	...
	onBackgroundMessage: Platform.isIOS ? null : myBackgroundMessageHandler,
	...
)

This solved the problem for me.

It still throws the same error output. Receiving push notifications when app is active works fine, it fails only in onResume and onLaunch states.

How have you implemented Application and MainActivity classes?

@urbanjagodic
Copy link
Author

Ok, it appears that that the issue was with notification data payload message, not with the
code implementation itself.

I just added

"data" : {
     "body" : "example body data",
     "title" : "example title data",
     "click_action": "FLUTTER_NOTIFICATION_CLICK",
 }

to notification message payload and now it works for both onResume and onLaunch states.

@alvinotienokelly
Copy link

So in the new firebase_messaging version, support for background messages was added. Actually, if you don't add background message handler, it failed to work on Android for me, so I added handler, according to docs:

_fcm.configure(
	...
	onBackgroundMessage: myBackgroundMessageHandler,
	...
)

Now, if you run code with background handler on iOS, it explodes with the error in this issue. So the solution is to set the handler to null for iOS:

_fcm.configure(
	...
	onBackgroundMessage: Platform.isIOS ? null : myBackgroundMessageHandler,
	...
)

This solved the problem for me.

but when i try to use onBackground message it says that it is an unknown parameter.

@divan
Copy link

divan commented Oct 10, 2019

@urbanjagodic, yes, that one is super easy to overlook too. Overall, for people who don't have prior experience with firebase messaging on Android, I feel like tons are default assumptions go wrong with using this plugin.
I also spent weeks(!) before realized that I need to add "FLUTTER_NOTIFICATION_CLICK" to the push notification payload (which still doesn't make much sense to me). Yet, it's in the README (not sure if I overlooked it at the beginning, or it's just you would never assume such thing to be required).

@alvinotienokelly, did you update your firebase_messaging plugin to the latest version?

Actually, I had to remove onBackgroundMessage handler completely, because it was causing SIGSEGV crash on Android (which cause wasn't obvious), and after spending a week debugging it I removed it waiting for the more stable code. (there a plenty of issues on this crash in both flutterfire and flutter repositories)

@iapicca iapicca added the impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) label Oct 24, 2019
@iapicca iapicca changed the title [Firebase messaging] <Background push notification handling - no implementation found for method FcmDartService#initialized> [firebase_messaging] <Background push notification handling - no implementation found for method FcmDartService#initialized> Oct 24, 2019
@changhouw
Copy link

i have the same issue, after replace barcode_scan version 1.0.0 with other plug-ins the problems gone, hope this help

@preetjdp
Copy link

preetjdp commented Nov 6, 2019

I've Managed to fix the no implantation error's by following these steps as mentioned here.

https://stackoverflow.com/a/55834355/12241836

  1. Move Application.kt / .java to the same folder as MainActivity.kt / .java
  2. Change android:name in AndroidMainfest.xml as done https://github.com/FirebaseExtended/flutterfire/blob/693c39fcffa46a83aa838eda0d15c1d37cc2dd91/packages/firebase_messaging/example/android/app/src/main/AndroidManifest.xml#L7
  3. flutter clean and rebuild. (This is important to do)

Also upon further reading i discovered that OnbackgroundMessage is fired only when the fcm notification is of a DATA TYPE

{
   "to": "USER_TOKEN_HERE",
   "data": {
      "uid": 123
   },
   "priority": "high"
}

Another important is thing to keep in mind is to have the OnMessageHandler be a top-level function, i.e, not be part of any class.

This PR has a lot of the talked upon.

@kaparray
Copy link

@preetjdp
@changhouw
@divan
@alvinotienokelly
@urbanjagodic
someone managed to call the onbackgroundmessage method using push?

@preetjdp
Copy link

@preetjdp
@changhouw
@divan
@alvinotienokelly
@urbanjagodic
someone managed to call the onbackgroundmessage method using push?

Yes I have managed to get it working, the aforementioned links helped me to get it work

@kaparray
Copy link

kaparray commented Dec 13, 2019

@preetjdp

I handle this exception

2019-12-13 13:34:58.705 20182-20280/com.example.push_demo E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method FcmDartService#initialized on channel plugins.flutter.io/firebase_messaging_background)
    #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)
    <asynchronous suspension>
    #1      _fcmSetupBackgroundChannel (package:firebase_messaging/firebase_messaging.dart:50:21)
    #2      _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:45:6)
    #3      _fcmSetupBackgroundChannel (package:firebase_messaging/firebase_messaging.dart:23:32)
    #4      _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:239:25)
    #5      _rootRun (dart:async/zone.dart:1126:13)
    #6      _CustomZone.run (dart:async/zone.dart:1023:19)
    #7      _runZoned (dart:async/zone.dart:1518:10)
    #8      runZoned (dart:async/zone.dart:1502:12)
    #9      _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:231:5)
    #10     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307:19)
    #11     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)

@woprandi
Copy link

Same error for me...

@shinewanna
Copy link

So in the new firebase_messaging version, support for background messages was added. Actually, if you don't add background message handler, it failed to work on Android for me, so I added handler, according to docs:

_fcm.configure(
	...
	onBackgroundMessage: myBackgroundMessageHandler,
	...
)

Now, if you run code with background handler on iOS, it explodes with the error in this issue. So the solution is to set the handler to null for iOS:

_fcm.configure(
	...
	onBackgroundMessage: Platform.isIOS ? null : myBackgroundMessageHandler,
	...
)

So,How to handle background message for IOS

@datayeah
Copy link

datayeah commented Jan 24, 2020

I dealed with the same crash ("registrar.activity() must not be null").
What fixed it for me was looking into the source code of the plugin that crashed.
I found, that a plugin i used (in the case of this ticket: BarcodeScanPlugin) called registrar.activity(). When the app gets a background notification, there is no activity, so it seemed to crash. i just edited the source code of the plugin and added a null check before the call of registrar.activity() and since then it works!

if (registrar.activity()==null){ return; }

Hope this helps!

@YonatanAmitzur
Copy link

i need to finally understand - there is no way to get onBackgroundMessage to work in IOS ?

@YonatanAmitzur
Copy link

so i got it to work for iOS background push, FLUTTER FIREBASE MESSAGING PLUGIN DOES SUPPORT IT !!!!!!!!!!! (just make sure you add to payload contentAvailable:true)
and i got the background notification into to the onResume handler in flutter (when the iOS app is in background just like the background handler - while the background handler works only for android)

but there is a problem and the problem is if you want to handle background push on iOS when the app is killed (not running in background) - and for that case, as i understand i need to implement push using pushKit - there is a flutter plugin for that

plugin:
https://pub.dev/packages/flutter_voip_push_notification

and you can integrate with firebase
see link below:

https://stackoverflow.com/questions/37326450/does-firebase-cloud-messaging-support-voip-pushkit-services

@Zazo032
Copy link
Contributor

Zazo032 commented Mar 2, 2020

Did anyone manage to solve this issue? It is blocking us to release background notifications for Android

@preetjdp
Copy link

preetjdp commented Mar 3, 2020

@Zazo032 I did manage to get this solved a month ago.
Give me a day to prepare a demo application

Although here are the steps that I followed.
#116 (comment)

@woutergoossens
Copy link

Ok, it appears that that the issue was with notification data payload message, not with the
code implementation itself.

I just added

"data" : {
     "body" : "example body data",
     "title" : "example title data",
     "click_action": "FLUTTER_NOTIFICATION_CLICK",
 }

to notification message payload and now it works for both onResume and onLaunch states.

Yes this did the trick for me after hours of searching! Thanks

@thesmalleyes
Copy link

hi @woutergoossens , could you share your onbackground handler function to show notification in background? and what widget that you used to make notification appears? and what version of your firebase messaging? i tried to find to find the way for a mont but i got nothing

@Vardiak
Copy link

Vardiak commented May 11, 2020

Why is it written nowhere that firebase messaging for Flutter doesn't support background messages on iOS ?

@iapicca
Copy link

iapicca commented May 15, 2020

#2180

@k00na
Copy link

k00na commented Jun 9, 2020

I had the same issue, this is what helped me solve it:

Inside my Application.java file I changed the code in registerWith() callback...

public class Application extends FlutterApplication implements PluginRegistrantCallback {


    @Override
    public void onCreate() {
        super.onCreate();
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
    }

    @Override
    public void registerWith(PluginRegistry registry) {
        // I've commented out the bellow line and added the FirebaseMessagingPlugin thingy instead
        //GeneratedPluginRegistrant.registerWith(registry);
        FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
    }
}

@sarope
Copy link

sarope commented Jun 25, 2020

@Zazo032 I did manage to get this solved a month ago.
Give me a day to prepare a demo application

Although here are the steps that I followed.
#116 (comment)

@preetjdp , did you ever make a sample application? I'd be interested in seeing how you accomplished this. I'm still having problems.

@preetjdp
Copy link

preetjdp commented Jun 25, 2020

@sarope Yes, I did.
Take a look https://github.com/preetjdp/YouOweMe

The Background FCM code can be found here:
https://github.com/preetjdp/YouOweMe/blob/Notification-Actions/mobileApp/android/app/src/main/kotlin/dev/preetjdp/youoweme/FCMApplication.kt

And that is being called in the AndroidManifest file.
https://github.com/preetjdp/YouOweMe/blob/7f84e8a3cdefed0e94a07c8ac64aef57c4df7d0c/mobileApp/android/app/src/main/AndroidManifest.xml#L12

@sarope If you need another hand hashing things out. Ping me on Twitter :D

@braysonjohn148
Copy link

braysonjohn148 commented Jul 3, 2020

It works fine for me, when the app is the background.(althought i had to pass only data) but when the app is terminated i don't get the notification. Android

@kjawadDeveloper
Copy link

This is what i used and it even works with v2 embedding
` public class MainActivity extends FlutterActivity /* implements PluginRegistrantCallback */ {

 @Override
    protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    // Create the NotificationChannel, but only on API 26+ because
    // the NotificationChannel class is new and not in the support library
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        String channelID = getString(R.string.notification_channel_id);
        CharSequence name = getString(R.string.notification_channel_name);
        String descriptionText = getString(R.string.notification_channel_desc);
        int importance = NotificationManager.IMPORTANCE_HIGH;

        NotificationChannel channel = new NotificationChannel(channelID, name, importance);
        channel.setDescription(descriptionText);

        // Register the channel with the system; you can't change the importance
        // or other notification behaviors after this
        NotificationManager notificationManager = getSystemService(NotificationManager.class);

        notificationManager.createNotificationChannel(channel);

    }


}

@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
            GeneratedPluginRegistrant.registerWith(flutterEngine);



       }

}
`

For the manifest use this

`











        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="@string/default_notification_channel_id"/>

        <!-- firebase notifications -->
        <intent-filter>
            <action android:name="FLUTTER_NOTIFICATION_CLICK" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

    </activity>

    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />

</application>
`

Remember to put the notification channel tag inside the activity tag not application tag

@nelvadas
Copy link

nelvadas commented Oct 5, 2020

Hello, anyone has an update on this subject or the proper way to solve this ? notification on ios in background or terminated mode are not working.

@marcschw
Copy link

so i got it to work for iOS background push, FLUTTER FIREBASE MESSAGING PLUGIN DOES SUPPORT IT !!!!!!!!!!! (just make sure you add to payload contentAvailable:true)
and i got the background notification into to the onResume handler in flutter (when the iOS app is in background just like the background handler - while the background handler works only for android)

but there is a problem and the problem is if you want to handle background push on iOS when the app is killed (not running in background) - and for that case, as i understand i need to implement push using pushKit - there is a flutter plugin for that

plugin:
https://pub.dev/packages/flutter_voip_push_notification

and you can integrate with firebase
see link below:

https://stackoverflow.com/questions/37326450/does-firebase-cloud-messaging-support-voip-pushkit-services

I'm trying to make background notifications work on IOS using this flutter plugin like you say but I'm stuck, I always get the "BadDeviceToken" error server-side. Could you share your code both on the flutter side and the node side how you use the FCM token for both firebase messaging and the VoIP push?

Thanks!
Marcel

@Salakar
Copy link
Member

Salakar commented Nov 4, 2020

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 Salakar closed this as completed Nov 4, 2020
@firebase firebase locked and limited conversation to collaborators Dec 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: messaging type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests