0 purchases
ecom flutter plugin
ecom_flutter_plugin #
一个与业务无关的通信插件
功能 #
本插件支持iOS和Android平台,用于Flutter与原生平台通信,与业务层解耦,需自消息收发体。支持:
Flutter向Native发送消息并接收回调
Native向Flutter发送消息并接收回调
使用 #
1、Flutter端 #
在demo中,业务层定义了NativeMessage类专门用来处理消息收发。具体步骤如下
1.1 初始化
业务层需初始化EcomFlutterPlugin
static EcomFlutterPlugin plugin = EcomFlutterPlugin();
1.2 设置原生消息的接收函数
plugin.setMethodCallHandler(_handleMessages);
_handleMessages为接收函数,具体见demo代码。
1.3 向原生端发送消息
EcomFlutterPlugin().postToNative(action, parame);
2、iOS端 #
相关代码可查看example目录下相关代码
2.1 接收消息
iOS在业务层需监听XMEcomFlutterPluginMessageNotification通过,并解析出call和result参数
2.2 向Flutter发送消息 #
[EcomFlutterPlugin invokeMethod:@"iOSToFlutter" arguments:@"我是iOS发给Flutter的消息额" result:^(id _Nullable result) {
NSLog(@"iOS主动发给Flutter消息后,收到的回参:%@",result);
}];
copied to clipboard
3、安卓端 #
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.