diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 42ebe0a..44839b0 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -9,22 +9,30 @@ import Flutter ) -> Bool { let controller: FlutterViewController = window?.rootViewController as! FlutterViewController let conversationChannel = FlutterMethodChannel(name: "beepvoice.app/conversation", binaryMessenger: controller) + let peerManager = PeerManager() conversationChannel.setMethodCallHandler({ (call: FlutterMethodCall, result: FlutterResult) -> Void in switch call.method { case "join": - print("Join executed") - result(String("")) + if let conversationId: String = call.arguments as? String { + peerManager.join(conversationId: conversationId) + print("Join executed") + } return case "exit": - print("exit executed") - result(String("")) + peerManager.exit() + print("Exit executed") return case "get": + if let activeConversation = peerManager.get() { + result(activeConversation) + } else { + result("") + } print("get executed") - result(String("c-d73b6afa2fe3685faad28eba36d8cd0a")) + return default: result(FlutterMethodNotImplemented) return diff --git a/lib/src/services/conversation_manager.dart b/lib/src/services/conversation_manager.dart index 490483b..47d30b6 100644 --- a/lib/src/services/conversation_manager.dart +++ b/lib/src/services/conversation_manager.dart @@ -6,7 +6,7 @@ class ConversationManager { Future join(String conversationId) async { try { - await channel.invokeMethod('join', {"conversationId": conversationId}); + await channel.invokeMethod('join', conversationId); } on PlatformException catch (e) { print(e); return -1; @@ -29,7 +29,7 @@ class ConversationManager { Future get() async { try { final String conversationId = await channel.invokeMethod('get'); - return ""; + return conversationId; } on PlatformException catch (e) { print(e); return "";