From aa93729f48762421658675800be68aee27b6d8fb Mon Sep 17 00:00:00 2001 From: Liuyf Date: Fri, 21 Feb 2025 09:25:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81command=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E5=9B=9E=E8=B0=83=E5=88=B0=E4=B8=9A=E5=8A=A1=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/src/main/java/com/jiguang/jpush/JPushHelper.java | 4 +++- lib/jpush_flutter.dart | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/jiguang/jpush/JPushHelper.java b/android/src/main/java/com/jiguang/jpush/JPushHelper.java index 0e3a96b..e888095 100644 --- a/android/src/main/java/com/jiguang/jpush/JPushHelper.java +++ b/android/src/main/java/com/jiguang/jpush/JPushHelper.java @@ -303,11 +303,12 @@ public class JPushHelper { } return extras; } + public static Map bundleToMap(Bundle bundle) { Map map = new HashMap<>(); if (bundle != null) { for (String key : bundle.keySet()) { - if("intent_component".equals(key)||"intent_action".equals(key)){ + if ("intent_component".equals(key) || "intent_action".equals(key)) { continue; } Object value = bundle.get(key); @@ -316,6 +317,7 @@ public class JPushHelper { } return map; } + public Map stringToMap(String extra) { Map useExtra = new HashMap(); try { diff --git a/lib/jpush_flutter.dart b/lib/jpush_flutter.dart index fd9ee45..759631a 100644 --- a/lib/jpush_flutter.dart +++ b/lib/jpush_flutter.dart @@ -29,6 +29,8 @@ class JPush { EventHandler? _onConnected; EventHandler? _onInAppMessageClick; EventHandler? _onInAppMessageShow; + EventHandler? _onCommandResult; + void setup({ String appKey = '', bool production = false, @@ -141,6 +143,7 @@ class JPush { EventHandler? onConnected, EventHandler? onInAppMessageClick, EventHandler? onInAppMessageShow, + EventHandler? onCommandResult, }) { print(flutter_log + "addEventHandler:"); @@ -152,11 +155,12 @@ class JPush { _onConnected = onConnected; _onInAppMessageClick = onInAppMessageClick; _onInAppMessageShow = onInAppMessageShow; + _onCommandResult = onCommandResult; _channel.setMethodCallHandler(_handleMethod); } Future _handleMethod(MethodCall call) async { - print(flutter_log + "_handleMethod:"); + print(flutter_log + "_handleMethod: ${call.method}"); switch (call.method) { case "onReceiveNotification": @@ -176,6 +180,8 @@ class JPush { return _onInAppMessageClick!(call.arguments.cast()); case "onInAppMessageShow": return _onInAppMessageShow!(call.arguments.cast()); + case "onCommandResult": + return _onCommandResult!(call.arguments.cast()); default: throw new UnsupportedError("Unrecognized Event"); }