Skip to content

Commit

Permalink
主动拉取extMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
charleyzhu committed Apr 9, 2021
1 parent 60a79cc commit 58eeebf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
companion object {

var callingChannel:MethodChannel? = null
// 主动获取的启动参数
var extMsg:String? = null

@JvmStatic
fun registerWith(registrar: PluginRegistry.Registrar) {
Expand Down Expand Up @@ -66,6 +68,7 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
call.method == "openWXApp" -> openWXApp(result)
call.method.startsWith("share") -> shareHandler?.share(call, result)
call.method == "isWeChatInstalled" -> WXAPiHandler.checkWeChatInstallation(result)
call.method == "getExtMsg" -> getExtMsg(result)
else -> result.notImplemented()
}
}
Expand All @@ -92,6 +95,10 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
}


private fun getExtMsg(result: MethodChannel.Result) {
result.success(extMsg)
}

private fun pay(call: MethodCall, result: MethodChannel.Result) {

if (WXAPiHandler.wxApi == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ object FluwxRequestHandler {
val result = mapOf(
"extMsg" to req.message.messageExt
)
FluwxPlugin.extMsg = req.message.messageExt;
FluwxPlugin.callingChannel?.invokeMethod("onWXShowMessageFromWX", result)
}

Expand Down
9 changes: 9 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ class ShareSelectorPage extends StatelessWidget {
return Center(
child: new ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: new OutlineButton(
onPressed: () async {
String extMsg = await getExtMsg();
print("extMsg:$extMsg\n");
},
child: const Text("Get ExtMessage")),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new OutlineButton(
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.4.2"
version: "2.6.3"
matcher:
dependency: transitive
description:
Expand Down
5 changes: 5 additions & 0 deletions lib/src/fluwx_iml.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ Future<bool> registerWxApi(
});
}

// get ext Message
Future<String> getExtMsg() async {
return await _channel.invokeMethod("getExtMsg");
}

///Share your requests to WeChat.
///This depends on the actual type of [model].
///see [_shareModelMethodMapper] for detail.
Expand Down

0 comments on commit 58eeebf

Please sign in to comment.