MajedDH / bring_to_foreground

A flutter plugin that brings an in-background android app to the foreground
MIT License
8 stars 20 forks source link

Unhandled Exception: MissingPluginException(No implementation found for method bringAppToForeground on channel bringtoforeground) #2

Open duck-dev-go opened 4 years ago

duck-dev-go commented 4 years ago

@MajedDH I get the following error when I try to call Bringtoforeground.bringAppToForeground();

I/flutter (24863): on background message
E/flutter (24863): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method bringAppToForeground on channel bringtoforeground)
E/flutter (24863): #0      MethodChannel._invokeMethod 
package:flutter/…/services/platform_channel.dart:154
E/flutter (24863): <asynchronous suspension>
E/flutter (24863): #1      MethodChannel.invokeMethod 
package:flutter/…/services/platform_channel.dart:329
E/flutter (24863): #2      Bringtoforeground.bringAppToForeground 
package:bringtoforeground/bringtoforeground.dart:8
E/flutter (24863): #3      CloudMessagingService.myBackgroundMessageHandler 
package:moto_picto/…/firebase/cloud_messaging_service.dart:74
E/flutter (24863): #4      _fcmSetupBackgroundChannel.<anonymous closure> 
package:firebase_messaging/firebase_messaging.dart:38
E/flutter (24863): #5      MethodChannel._handleAsMethodCall 
package:flutter/…/services/platform_channel.dart:409
E/flutter (24863): #6      MethodChannel.setMethodCallHandler.<anonymous closure> 
package:flutter/…/services/platform_channel.dart:377
E/flutter (24863): #7      _DefaultBinaryMessenger.handlePlatformMessage 
package:flutter/…/services/binding.dart:199
E/flutter (24863): #8      _invoke3.<anonymous closure>  (dart:ui/hooks.dart:290:15)
E/flutter (24863): #9      _rootRun  (dart:async/zone.dart:1184:13)
E/flutter (24863): #10     _CustomZone.run  (dart:async/zone.dart:1077:19)
E/flutter (24863): #11     _CustomZone.runGuarded  (dart:async/zone.dart:979:7)
E/flutter (24863): #12     _invoke3  (dart:ui/hooks.dart:289:10)
E/flutter (24863): #13     _dispatchPlatformMessage  (dart:ui/hooks.dart:164:5)
E/flutter (24863):

I call the function from my cloud messaging background handler

  static Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) async {
    print('on background message');
      Bringtoforeground.bringAppToForeground();
  }
MajedDH commented 4 years ago

Firebase has a problem with background message handler See here: #1878

It's not been solved yet.

In that case I had to fork the fireflutter plugin and override onMessageRecieved, take a look at this file: CustomFlutterFirebaseMessagingService.java

skemuel007 commented 3 years ago

Currently facing the same issue, couldn't deduce the source, had to start the project from scratch