flutter-webrtc / callkeep

iOS CallKit and Android ConnectionService for Flutter
MIT License
131 stars 142 forks source link

Unhandled Exception: MissingPluginException(No implementation found for method setup on channel FlutterCallKeep.Method) #52

Closed xyzbilal closed 3 years ago

xyzbilal commented 3 years ago

Hi, I m testing example app of plugin. everything works fine when app is foreground but when app is in backround I am getting error below.

my firebase message payload is :

{
    "registration_ids":["d08bLhJpQn6-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3FGiY-"
],
    "data":{ "uuid": "xxxxx-xxxxx-xxxxx-xxxxx",
    "caller_id": "+8618612345678",
    "caller_name": "hello",
    "caller_id_type": "number", 
    "has_video": false}

}

Error message:

/flutter (18141): backgroundMessage: message => {data: {caller_id: +8618612345678, uuid: xxxxx-xxxxx-xxxxx-xxxxx, has_video: false, caller_id_type: number, caller_name: hello}}
I/flutter (18141): backgroundMessage: displayIncomingCall (+8618612345678)
E/flutter (18141): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method displayIncomingCall on channel FlutterCallKeep.Method)
E/flutter (18141): #0      MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:157
E/flutter (18141): <asynchronous suspension>
E/flutter (18141): #1      MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:332
E/flutter (18141): #2      FlutterCallkeep.displayIncomingCall
package:callkeep/src/api.dart:83
E/flutter (18141): #3      myBackgroundMessageHandler
package:callkit/main.dart:81
E/flutter (18141): #4      _fcmSetupBackgroundChannel.<anonymous closure>
package:firebase_messaging/firebase_messaging.dart:38
E/flutter (18141): #5      MethodChannel._handleAsMethodCall
package:flutter/…/services/platform_channel.dart:430
E/flutter (18141): #6      MethodChannel.setMethodCallHandler.<anonymous closure>
package:flutter/…/services/platform_channel.dart:383
E/flutter (18141): #7      _DefaultBinaryMessenger.handlePlatformMessage
package:flutter/…/services/binding.dart:283
E/flutter (18141): #8      _invoke3.<anonymous closure> (dart:ui/hooks.dart:280:15)
E/flutter (18141): #9      _rootRun (dart:async/zone.dart:1190:13)
E/flutter (18141): #10     _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (18141): #11     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (18141): #12     _invoke3 (dart:ui/hooks.dart:279:10)
E/flutter (18141): #13     _dispatchPlatformMessage (dart:ui/hooks.dart:154:5)
E/flutter (18141):
E/flutter (18141): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method backToForeground on channel FlutterCallKeep.Method)
E/flutter (18141): #0      MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:157
E/flutter (18141): <asynchronous suspension>
E/flutter (18141): #1      MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:332
E/flutter (18141): #2      FlutterCallkeep.backToForeground
package:callkeep/src/api.dart:260
E/flutter (18141): #3      myBackgroundMessageHandler
E/flutter (18141): #4      _fcmSetupBackgroundChannel.<anonymous closure>
package:firebase_messaging/firebase_messaging.dart:38
E/flutter (18141): #5      _fcmSetupBackgroundChannel.<anonymous closure>
package:firebase_messaging/firebase_messaging.dart:31
E/flutter (18141): #6      MethodChannel._handleAsMethodCall
package:flutter/…/services/platform_channel.dart:430
E/flutter (18141): #7      MethodChannel.setMethodCallHandler.<anonymous closure>
package:flutter/…/services/platform_channel.dart:383
E/flutter (18141): #8      _DefaultBinaryMessenger.handlePlatformMessage
package:flutter/…/services/binding.dart:283
E/flutter (18141): #9      _invoke3.<anonymous closure> (dart:ui/hooks.dart:280:15)
E/flutter (18141): #10     _rootRun (dart:async/zone.dart:1190:13)
E/flutter (18141): #11     _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (18141): #12     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (18141): #13     _invoke3 (dart:ui/hooks.dart:279:10)
E/flutter (18141): #14     _dispatchPlatformMessage (dart:ui/hooks.dart:154:5)

I tried it samsung galaxy j6+ android 10

any idea will be appriciated.

xyzbilal commented 3 years ago

implementing plugin to Application.java like below solved my problem.

package com.xxxxxxxxx.callkit;

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;
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin;
import com.github.cloudwebrtc.flutter_callkeep.FlutterCallkeepPlugin;

public class Application extends FlutterApplication implements PluginRegistrantCallback {

    @Override

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

    @Override
    public void registerWith(PluginRegistry pluginRegistry) {

        FirebaseMessagingPlugin.registerWith(pluginRegistry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
        FlutterCallkeepPlugin.registerWith(pluginRegistry.registrarFor("com.github.cloudwebrtc.flutter_callkeep"));
    }
}

solution mentioned at this thread: https://github.com/flutter-webrtc/callkeep/issues/21#issuecomment-718883312

cloudwebrtc commented 3 years ago

You need to modify the Application.java code and manually register the plug-in.

Application.java

public class Application extends FlutterApplication implements PluginRegistrantCallback {
    @Override
    public void onCreate() {
        super.onCreate();
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
    }

    @Override
    public void registerWith(PluginRegistry pluginRegistry) {
        FirebaseMessagingPlugin.registerWith(pluginRegistry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
        FlutterCallkeepPlugin.registerWith(pluginRegistry.registrarFor("com.github.cloudwebrtc.flutter_callkeep.FlutterCallkeepPlugin"));
    }
}