修改getPhoneNumber首次不触发回调的问题

master
wanghualei 2023-06-08 23:29:36 +08:00
parent 51b2f827f0
commit 8b8b599f71
5 changed files with 35 additions and 21 deletions

View File

@ -131,12 +131,15 @@ class _MyAppState extends State<MyApp> {
_buildAppletItem(appletId, "打开小程序", () {
// Mop.instance.openApplet(appletId,
// path: 'pages/index/index', query: '');
TranstionStyle style = TranstionStyle.TranstionStyleUp;
if (appletId == "5f72e3559a6a7900019b5baa") {
style = TranstionStyle.TranstionStylePush;
}
RemoteAppletRequest request = RemoteAppletRequest(apiServer: 'https://api.finclip.com', appletId: appletId, transitionStyle: style);
Mop.instance.startApplet(request);
// TranstionStyle style = TranstionStyle.TranstionStyleUp;
// if (appletId == "5f72e3559a6a7900019b5baa") {
// style = TranstionStyle.TranstionStylePush;
// }
// RemoteAppletRequest request = RemoteAppletRequest(apiServer: 'https://api.finclip.com', appletId: appletId, transitionStyle: style);
// Mop.instance.startApplet(request);
Mop.instance.qrcodeOpenApplet('https://api.finclip.com/api/v1/mop/runtime/applet/-f-MGYzN2Q1YTYzMmI2MWIyZg--');
}),
_buildAppletItem(appletId, "finishRunningApplet", () {
Mop.instance.finishRunningApplet(appletId, true);
@ -184,8 +187,8 @@ class MyAppletHandler extends AppletHandler {
@override
bool customCapsuleMoreButtonClick(String appId) {
print("customCapsuleMoreButtonClick---");
toAppMessageChannel.invokeMethod("showCustomMoreView", {"appId": appId});
return true;
// toAppMessageChannel.invokeMethod("showCustomMoreView", {"appId": appId});
return false;
}
@override
@ -195,14 +198,23 @@ class MyAppletHandler extends AppletHandler {
@override
Future<List<CustomMenu>> getCustomMenus(String appId) {
List<CustomMenu> customMenus = [];
List<CustomMenu> customMenus = [
CustomMenu('WXShareAPPFriends', 'https://img1.baidu.com/it/u=2878938773,1765835171&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500', '微信好朋友', 'common'),
CustomMenu('WXShareAPPMoments', 'https://img2.baidu.com/it/u=3113705544,436318069&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500', '微信朋友圈', 'common'),
// CustomMenu('WXShareAPPFriends', 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSpvugSNLs9R7iopz_noeotAelvgzYj-74iCg&usqp=CAU', '微信好朋友', 'common'),
// CustomMenu('WXShareAPPMoments', 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR7cO4KB4e5-Ugdcq4pIyWunliH7LZRZzguKQ&usqp=CAU', '微信朋友圈', 'common'),
];
return Future.value(customMenus);
}
@override
Future<void> getMobileNumber(Function(dynamic params) param0) {
Future<void> getMobileNumber(Function(dynamic params) callback) {
// TODO: implement getMobileNumber
throw UnimplementedError();
Map<String, dynamic> result = {"phone": '18607180143',"other":'abc123'};
print('getMobileNumber:' + result.toString());
callback(result);
return Future.value(null);
}
@override

View File

@ -115,7 +115,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.40.9"
version: "2.40.11"
path:
dependency: transitive
description:

View File

@ -180,8 +180,9 @@ static NSString *scheme = @"fatae55433be2f62915";//App对应的scheme
NSDictionary *params = @{@"name":@"getPhoneNumber"};
FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel];
self.bindGetPhoneNumbers = bindGetPhoneNumber;
NSLog(@"getPhoneNumberWithAppletInfo");
[channel invokeMethod:@"extensionApi:getPhoneNumber" arguments:params result:^(id _Nullable result) {
self.bindGetPhoneNumbers = bindGetPhoneNumber;
// !self.bindGetPhoneNumbers?: bindGetPhoneNumber(result);
}];

View File

@ -127,12 +127,13 @@ static MopPlugin *_instance;
}
else if ([@"getPhoneNumberResult" isEqualToString:call.method]) {
if ([MOPAppletDelegate instance].bindGetPhoneNumbers) {
NSDictionary *dic = [[NSDictionary alloc] initWithDictionary:call.arguments];
NSString *jsonString = [dic[@"phone"] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *error;
NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
[MOPAppletDelegate instance].bindGetPhoneNumbers(jsonDic);
[MOPAppletDelegate instance].bindGetPhoneNumbers(call.arguments);
// NSDictionary *dic = [[NSDictionary alloc] initWithDictionary:call.arguments];
// NSString *jsonString = [dic[@"phone"] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
// NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
// NSError *error;
// NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
// [MOPAppletDelegate instance].bindGetPhoneNumbers(jsonDic);
}
}
else {

View File

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