Merge branch 'master' into 2.39.0

master
zhongweiguang 2022-11-24 23:16:50 +08:00
commit ed40e68351
3 changed files with 21 additions and 12 deletions

View File

@ -23,9 +23,10 @@
[channel invokeMethod:api arguments:param result:^(id _Nullable result) { [channel invokeMethod:api arguments:param result:^(id _Nullable result) {
NSLog(@"extensionApi reslut:%@",result); NSLog(@"extensionApi reslut:%@",result);
// flutter // flutter
BOOL isFlutterError = [result isKindOfClass:[FlutterError class]] || result == FlutterMethodNotImplemented; // BOOL isFlutterError = [result isKindOfClass:[FlutterError class]] || result == FlutterMethodNotImplemented;
if (isFlutterError) { BOOL isValid = [result isKindOfClass:[NSDictionary class]];
NSLog(@"extensionApi reslut:fail"); if (!isValid) {
NSLog(@"extensionApi reslut is not NSDictionary");
callback(FATExtensionCodeFailure,nil); callback(FATExtensionCodeFailure,nil);
return; return;
} }

View File

@ -17,7 +17,7 @@ A finclip miniprogram flutter sdk.
s.dependency 'Flutter' s.dependency 'Flutter'
s.ios.deployment_target = '9.0' s.ios.deployment_target = '9.0'
s.dependency 'FinApplet' , '2.38.5' s.dependency 'FinApplet' , '2.38.7'
s.dependency 'FinAppletExt' , '2.38.5' s.dependency 'FinAppletExt' , '2.38.7'
end end

View File

@ -7,7 +7,8 @@ import 'package:mop/api.dart';
typedef MopEventCallback = void Function(dynamic event); typedef MopEventCallback = void Function(dynamic event);
typedef MopEventErrorCallback = void Function(dynamic event); typedef MopEventErrorCallback = void Function(dynamic event);
typedef ExtensionApiHandler = Future Function(dynamic params); typedef ExtensionApiHandler = Future<Map<String, dynamic>> Function(dynamic params);
typedef MopAppletHandler = Future Function(dynamic params);
class FinStoreConfig { class FinStoreConfig {
///SDK Key ///SDK Key
@ -328,6 +329,8 @@ class Mop {
late int eventId = 0; late int eventId = 0;
final List<Map<String, dynamic>> _mopEventQueye = <Map<String, dynamic>>[]; final List<Map<String, dynamic>> _mopEventQueye = <Map<String, dynamic>>[];
final Map<String, MopAppletHandler> _appletHandlerApis = {};
final Map<String, ExtensionApiHandler> _extensionApis = {}; final Map<String, ExtensionApiHandler> _extensionApis = {};
Map<String, ExtensionApiHandler> _webExtensionApis = {}; Map<String, ExtensionApiHandler> _webExtensionApis = {};
@ -371,6 +374,11 @@ class Mop {
if (handler != null) { if (handler != null) {
return await handler(call.arguments); return await handler(call.arguments);
} }
final apiHandler = _appletHandlerApis[name];
if (apiHandler != null) {
return await apiHandler(call.arguments);
}
} else if (call.method.startsWith("webExtentionApi:")) { } else if (call.method.startsWith("webExtentionApi:")) {
final name = call.method.substring("webExtentionApi:".length); final name = call.method.substring("webExtentionApi:".length);
final handler = _webExtensionApis[name]; final handler = _webExtensionApis[name];
@ -572,13 +580,13 @@ class Mop {
/// ///
/// ///
void registerAppletHandler(AppletHandler handler) { void registerAppletHandler(AppletHandler handler) {
_extensionApis["forwardApplet"] = (params) async { _appletHandlerApis["forwardApplet"] = (params) async {
handler.forwardApplet(Map<String, dynamic>.from(params)); handler.forwardApplet(Map<String, dynamic>.from(params));
}; };
_extensionApis["getUserInfo"] = (params) { _appletHandlerApis["getUserInfo"] = (params) {
return handler.getUserInfo(); return handler.getUserInfo();
}; };
_extensionApis["getCustomMenus"] = (params) async { _appletHandlerApis["getCustomMenus"] = (params) async {
final res = await handler.getCustomMenus(params["appId"]); final res = await handler.getCustomMenus(params["appId"]);
List<Map<String, dynamic>> list = []; List<Map<String, dynamic>> list = [];
res.forEach((element) { res.forEach((element) {
@ -592,14 +600,14 @@ class Mop {
debugPrint("registerAppletHandler getCustomMenus list $list"); debugPrint("registerAppletHandler getCustomMenus list $list");
return list; return list;
}; };
_extensionApis["onCustomMenuClick"] = (params) async { _appletHandlerApis["onCustomMenuClick"] = (params) async {
return handler.onCustomMenuClick( return handler.onCustomMenuClick(
params["appId"], params["path"], params["menuId"], params["appInfo"]); params["appId"], params["path"], params["menuId"], params["appInfo"]);
}; };
_extensionApis["appletDidOpen"] = (params) async { _appletHandlerApis["appletDidOpen"] = (params) async {
return handler.appletDidOpen(params["appId"]); return handler.appletDidOpen(params["appId"]);
}; };
_extensionApis["getPhoneNumber"] = (params) async { _appletHandlerApis["getPhoneNumber"] = (params) async {
return handler.getMobileNumber((params0) => return handler.getMobileNumber((params0) =>
{_channel.invokeMethod("getPhoneNumberResult", params0)}); {_channel.invokeMethod("getPhoneNumberResult", params0)});
}; };