提交 f5852d9c authored 作者: JarvanMo's avatar JarvanMo

fix bugs and test share text

上级 53155a88
package com.jarvan.fluwx
import android.util.Log
import com.jarvan.fluwx.constant.CallResult
import com.jarvan.fluwx.constant.WeChatPluginMethods
import com.jarvan.fluwx.handler.WeChatPluginHandler
......@@ -22,19 +23,23 @@ class FluwxPlugin(private var registrar: Registrar) : MethodCallHandler {
}
override fun onMethodCall(call: MethodCall, result: Result): Unit {
when {
WeChatPluginMethods.INIT == call.method -> {
if(call.method == WeChatPluginMethods.INIT ){
val api = WXAPIFactory.createWXAPI(registrar.context().applicationContext, call.arguments as String?)
api.registerApp(call.arguments as String)
WeChatPluginHandler.setWxApi(api)
return
}
WeChatPluginHandler.apiIsNull() -> {
if(WeChatPluginHandler.apiIsNull()){
result.error(CallResult.RESULT_API_NULL, "please config wxapi first", null)
return
}
call.method.startsWith("share") -> {
if( call.method.startsWith("share")){
WeChatPluginHandler.handle(call, result)
}else{
result.notImplemented()
}
}
}
}
......@@ -47,7 +47,7 @@ object WeChatPluginHandler {
fun handle(call: MethodCall, result: MethodChannel.Result) {
if (wxApi!!.isWXAppInstalled) {
if (!wxApi!!.isWXAppInstalled) {
result.error(CallResult.RESULT_WE_CHAT_NOT_INSTALLED, CallResult.RESULT_WE_CHAT_NOT_INSTALLED, null)
return
}
......
......@@ -45,7 +45,7 @@ android {
signingConfigs {
debug {
storeFile file("../debug.keystore")
storeFile file("debug.keystore")
}
}
}
......
......@@ -17,7 +17,7 @@ class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
initPlatformState();
// initPlatformState();
Fluwx.init("wxd930ea5d5a258f4f");
}
......@@ -49,7 +49,11 @@ class _MyAppState extends State<MyApp> {
title: const Text('Plugin example app'),
),
body: new Center(
child: new Text('Running on: $_platformVersion\n'),
child:
new FlatButton(onPressed: () {
var fluwx = Fluwx();
fluwx.shareText(WeChatShareTextModel(text: "share text from flutter",transaction: "hehe"));
}, child: new Text("share text to wechat")),
),
),
);
......
......@@ -6,13 +6,13 @@ import 'package:fluwx/src/wechat_share_models.dart';
class Fluwx {
static const MethodChannel _channel = const MethodChannel('wechat_plugin');
static const MethodChannel _channel = const MethodChannel('fluwx');
StreamController<Map> _responseStreamController = new StreamController.broadcast();
Stream<Map> get weChatResponseUpdate=>_responseStreamController.stream;
static Future<int> init(String appId) async{
return await _channel.invokeMethod("initWeChat");
return await _channel.invokeMethod("initWeChat",appId);
}
void listen(){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论