Closed AbdurrehmanSubhani closed 1 year ago
Hello @AbdurrehmanSubhani, userInfo should be passed as a String:String hash map, try to pass data in next format:
final callerData = { "callerName": qbUser!.fullName, };
The userInfo type set in the sdk is set Map<String,Object?> hence im not able to assign the callerData mentioned above: error: The argument type 'Map<String, String?>' can't be assigned to the parameter type 'Map<String, Object>?'.
Hello @AbdurrehmanSubhani I have tested in version Flutter Quickblox SDK 0.12.4 and the code below works fine:
Caller side:
Map<String, Object> callerInfo = {};
callerInfo["callerData"] = qbUser?.fullName ?? "FullName or User is NULL";
QBRTCSession? session = await QB.webrtc.call(OPPONENTS_IDS, QBRTCSessionTypes.AUDIO, userInfo: callerInfo);
Opponent side:
_callSubscription = await QB.webrtc.subscribeRTCEvent(QBRTCEventTypes.CALL, (data) {
Map<dynamic, dynamic> payloadMap = Map<dynamic, dynamic>.from(data["payload"]);
String callerData = payloadMap["userInfo"]["callerData"];
/*Some code for handle calls*/
});
Thanks, the solution is working! @kirillTolmachev i tried finding an example on the sdk documentation but couldn't find any, it would be great if the code provided above is added to the sdk documentation!
Hey, what is the correct format for adding userInfo data while making a call. I want to display the caller name while receiving a call on the callee side and hence trying to send information through userInfo. I have tried the following approaches:
Approach 1: try { QBRTCSession? session = await QB.webrtc.call(opponentIds, QBRTCSessionTypes.AUDIO, userInfo: { "callerData": qbUser!, });
_sessionId = session!.id; logger.d("The call was initiated for session id: $_sessionId");
_sessionId = _sessionId; return sessionId; } on PlatformException catch (e) { logger.d(e); return null; } error logs: Invalid argument: Instance of 'QBUser'
Approach 2: try { final callerData = { "callerData": { "name": qbUser!.fullName, } }; QBRTCSession? session = await QB.webrtc .call(opponentIds, QBRTCSessionTypes.AUDIO, userInfo: callerData);
_sessionId = session!.id;
logger.d("The call was initiated for session id: $_sessionId");
_sessionId = _sessionId; return sessionId; } on PlatformException catch (e) { logger.d(e); return null; } error logs: PlatformException(error, java.util.HashMap cannot be cast to java.lang.String, null, java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.String I/flutter ( 8716): β π at com.quickblox.quickblox_sdk.webrtc.WebRTCModule.call(WebRTCModule.java:175) I/flutter ( 8716): β π at com.quickblox.quickblox_sdk.webrtc.WebRTCModule.handleMethod(WebRTCModule.java:85) I/flutter ( 8716): β π at com.quickblox.quickblox_sdk.webrtc.WebRTCModule$$ExternalSyntheticLambda0.onMethodCall(Unknown Source:2) I/flutter ( 8716): β π at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262) I/flutter ( 8716): β π at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) I/flutter ( 8716): β π at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319) I/flutter ( 8716): β π at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) I/flutter ( 8716): β π at android.os.Handler.handleCallback(Handler.java:942) I/flutter ( 8716): β π at android.os.Handler.dispatchMessage(Handler.java:99) I/flutter ( 8716): β π at android.os.Looper.loopOnce(Looper.java:201) I/flutter ( 8716): β π at android.os.Looper.loop(Looper.java:288) I/flutter ( 8716): β π at android.app.ActivityThread.main(ActivityThread.java:7898) I/flutter ( 8716): β π at java.lang.reflect.Method.invoke(Native Method) I/flutter ( 8716): β π at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) I/flutter ( 8716): β π at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) I/flutter ( 8716): β π )