|
...
|
...
|
@@ -57,62 +57,134 @@ FlutterMethodChannel *channel; |
|
|
|
}
|
|
|
|
|
|
|
|
- (void)shareImage:(FlutterMethodCall *)call result:(FlutterResult)result {
|
|
|
|
|
|
|
|
WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
WWKMessageImageAttachment *attachment = [[WWKMessageImageAttachment alloc] init];
|
|
|
|
attachment.filename = @"icon.jpg";
|
|
|
|
attachment.path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"jpg"];
|
|
|
|
// NSURL *imageURL = [NSURL URLWithString:@"http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png"];
|
|
|
|
// //下载图片
|
|
|
|
// NSData *data= [NSData dataWithContentsOfURL:imageURL];
|
|
|
|
// attachment.data = data;
|
|
|
|
req.attachment = attachment;
|
|
|
|
[WWKApi sendReq:req];
|
|
|
|
[WWKApi registerApp:@"wwauthbdca186ec4257973000006" corpId:@"wwbdca186ec4257973" agentId:@"1000006"];
|
|
|
|
|
|
|
|
dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
|
|
|
|
dispatch_async(globalQueue, ^{
|
|
|
|
|
|
|
|
|
|
|
|
// 使用NSURLSession异步请求网络图片
|
|
|
|
NSURL *imageURL = [NSURL URLWithString:call.arguments[@"path"]];
|
|
|
|
NSURLRequest *request = [NSURLRequest requestWithURL:imageURL];
|
|
|
|
|
|
|
|
// 创建URLSession并开始任务
|
|
|
|
NSURLSession *session = [NSURLSession sharedSession];
|
|
|
|
NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:
|
|
|
|
^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
|
|
|
if (error) {
|
|
|
|
// 处理错误
|
|
|
|
NSLog(@"Error: %@", error);
|
|
|
|
} else {
|
|
|
|
// 成功获取数据,转换为NSData
|
|
|
|
NSData *imageData = data;
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
WWKMessageImageAttachment *attachment = [[WWKMessageImageAttachment alloc] init];
|
|
|
|
// attachment.filename = @"icon.jpg";
|
|
|
|
// attachment.path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"jpg"];
|
|
|
|
// NSURL *imageURL = [NSURL URLWithString:@"http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png"];
|
|
|
|
// //下载图片
|
|
|
|
// NSData *data= [NSData dataWithContentsOfURL:imageURL];
|
|
|
|
attachment.filename = @"share_image";
|
|
|
|
attachment.data = imageData;
|
|
|
|
req.attachment = attachment;
|
|
|
|
[WWKApi sendReq:req];
|
|
|
|
authResult = result;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 此处可以使用imageData,例如保存到本地或者用于其他处理
|
|
|
|
// 保存到本地示例代码
|
|
|
|
// [imageData writeToFile:@"/path/to/save/image.png" atomically:YES];
|
|
|
|
|
|
|
|
// 或者直接使用
|
|
|
|
// UIImage *image = [UIImage imageWithData:imageData];
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
|
|
|
|
// 启动任务
|
|
|
|
[task resume];
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
// WWKMessageImageAttachment *attachment = [[WWKMessageImageAttachment alloc] init];
|
|
|
|
// attachment.filename = @"icon.jpg";
|
|
|
|
// attachment.path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"jpg"];
|
|
|
|
// // NSURL *imageURL = [NSURL URLWithString:@"http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png"];
|
|
|
|
// // //下载图片
|
|
|
|
// // NSData *data= [NSData dataWithContentsOfURL:imageURL];
|
|
|
|
// // attachment.data = data;
|
|
|
|
// req.attachment = attachment;
|
|
|
|
// [WWKApi sendReq:req];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)shareMiniProgram:(FlutterMethodCall *)call result:(FlutterResult)result {
|
|
|
|
|
|
|
|
WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
WWKMessageMiniAppAttachment *attachment = [[WWKMessageMiniAppAttachment alloc] init];
|
|
|
|
attachment.userName = @"gh_487873d353b3@app"; //必须是应用关联的小程序,注意要有@app后缀
|
|
|
|
attachment.path = @"pages/customer/index.html?id=563971&hasInvitation=1&hasSellerShare=1&uid=7035";
|
|
|
|
// attachment.hdImageData = UIImageJPEGRepresentation([UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bg_error" ofType:@"png"]], 1.0f);
|
|
|
|
NSString *hdImageData = call.arguments[@"hdImageData"];
|
|
|
|
NSURL *imageURL = [NSURL URLWithString:hdImageData];
|
|
|
|
//下载图片
|
|
|
|
NSData *data= [NSData dataWithContentsOfURL:imageURL];
|
|
|
|
attachment.hdImageData = data;
|
|
|
|
// attachment.hdImageData = UIImageJPEGRepresentation([UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"jpg"]], 1.0f);
|
|
|
|
attachment.title = @"您预订的长安大排档总店(测试),已经安排,点击查看详情";
|
|
|
|
req.attachment = attachment;
|
|
|
|
[WWKApi sendReq:req];
|
|
|
|
authResult = result;
|
|
|
|
|
|
|
|
// dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
|
|
|
|
// dispatch_async(globalQueue, ^{
|
|
|
|
// NSString *hdImageData = call.arguments[@"hdImageData"];
|
|
|
|
// NSURL *imageURL = [NSURL URLWithString:hdImageData];
|
|
|
|
// //下载图片
|
|
|
|
// NSData *data= [NSData dataWithContentsOfURL:imageURL];
|
|
|
|
// dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
// WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
// WWKMessageMiniAppAttachment *attachment = [[WWKMessageMiniAppAttachment alloc] init];
|
|
|
|
// attachment.userName = call.arguments[@"userName"]; //必须是应用关联的小程序,注意要有@app后缀
|
|
|
|
// attachment.path = call.arguments[@"path"];
|
|
|
|
|
|
|
|
// attachment.hdImageData = data;
|
|
|
|
// // attachment.hdImageData = UIImageJPEGRepresentation([UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"jpg"]], 1.0f);
|
|
|
|
// attachment.title = call.arguments[@"title"];
|
|
|
|
// req.attachment = attachment;
|
|
|
|
// [WWKApi sendReq:req];
|
|
|
|
// // result([NSString stringWithFormat:@"%hhd",[WWKApi sendReq:req]);
|
|
|
|
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// });
|
|
|
|
// WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
// WWKMessageMiniAppAttachment *attachment = [[WWKMessageMiniAppAttachment alloc] init];
|
|
|
|
// attachment.userName = @"gh_487873d353b3@app"; //必须是应用关联的小程序,注意要有@app后缀
|
|
|
|
// attachment.path = @"pages/customer/index.html?id=563971&hasInvitation=1&hasSellerShare=1&uid=7035";
|
|
|
|
// // attachment.hdImageData = UIImageJPEGRepresentation([UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bg_error" ofType:@"png"]], 1.0f);
|
|
|
|
// NSString *hdImageData = call.arguments[@"hdImageData"];
|
|
|
|
// NSURL *imageURL = [NSURL URLWithString:hdImageData];
|
|
|
|
// //下载图片
|
|
|
|
// NSData *data= [NSData dataWithContentsOfURL:imageURL];
|
|
|
|
// attachment.hdImageData = data;
|
|
|
|
// // attachment.hdImageData = UIImageJPEGRepresentation([UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"jpg"]], 1.0f);
|
|
|
|
// attachment.title = @"您预订的长安大排档总店(测试),已经安排,点击查看详情";
|
|
|
|
// req.attachment = attachment;
|
|
|
|
// [WWKApi sendReq:req];
|
|
|
|
// authResult = result;
|
|
|
|
|
|
|
|
dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
|
|
|
|
dispatch_async(globalQueue, ^{
|
|
|
|
|
|
|
|
|
|
|
|
// 使用NSURLSession异步请求网络图片
|
|
|
|
NSURL *imageURL = [NSURL URLWithString:call.arguments[@"hdImageData"]];
|
|
|
|
NSURLRequest *request = [NSURLRequest requestWithURL:imageURL];
|
|
|
|
|
|
|
|
// 创建URLSession并开始任务
|
|
|
|
NSURLSession *session = [NSURLSession sharedSession];
|
|
|
|
NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:
|
|
|
|
^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
|
|
|
if (error) {
|
|
|
|
// 处理错误
|
|
|
|
NSLog(@"Error: %@", error);
|
|
|
|
} else {
|
|
|
|
// 成功获取数据,转换为NSData
|
|
|
|
NSData *imageData = data;
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
|
|
|
|
|
|
|
WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
WWKMessageMiniAppAttachment *attachment = [[WWKMessageMiniAppAttachment alloc] init];
|
|
|
|
attachment.userName = call.arguments[@"userName"]; //必须是应用关联的小程序,注意要有@app后缀
|
|
|
|
attachment.path = call.arguments[@"path"];
|
|
|
|
attachment.hdImageData =imageData;
|
|
|
|
|
|
|
|
attachment.title = call.arguments[@"title"];
|
|
|
|
req.attachment = attachment;
|
|
|
|
[WWKApi sendReq:req];
|
|
|
|
authResult = result;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}}];
|
|
|
|
|
|
|
|
|
|
|
|
// 启动任务
|
|
|
|
[task resume];
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
...
|
...
|
@@ -176,7 +248,7 @@ FlutterMethodChannel *channel; |
|
|
|
NSString *corpId = call.arguments[@"corpId"]; // 第三方App所属企业的ID
|
|
|
|
NSString *agentId = call.arguments[@"agentId"]; // 第三方App在企业内部的ID
|
|
|
|
// BOOL isWeChatRegistered = [WXApi registerApp:appId universalLink:universalLink];
|
|
|
|
BOOL isWWKRegistered = [WWKApi registerApp:@"wwauthbdca186ec4257973000006" corpId:@"wwbdca186ec4257973" agentId:@"1000006"];
|
|
|
|
BOOL isWWKRegistered = [WWKApi registerApp:scheme corpId:corpId agentId:agentId];
|
|
|
|
result(@(isWWKRegistered));
|
|
|
|
// result(@(isWeChatRegistered));
|
|
|
|
}
|
|
...
|
...
|
@@ -236,17 +308,12 @@ FlutterMethodChannel *channel; |
|
|
|
authResult(mDic);
|
|
|
|
// [channel invokeMethod:@"auth" arguments:mDic];
|
|
|
|
}else if([resp isKindOfClass:[WWKSendMessageResp class]]){
|
|
|
|
// WWKSendMessageResp *r = (WWKSendMessageResp *)resp;
|
|
|
|
// NSMutableDictionary *mDic = [[NSMutableDictionary alloc]init];
|
|
|
|
// if([self isBlankString:[NSString stringWithFormat:@"%d",r.errCode]]){
|
|
|
|
// [mDic setObject:@"1" forKey:@"errCode"];
|
|
|
|
// [mDic setObject:@"" forKey:@"code"];
|
|
|
|
// }else{
|
|
|
|
// [mDic setObject:@"0" forKey:@"errCode"];
|
|
|
|
// [mDic setObject:r.errStr forKey:@"code"];
|
|
|
|
// }
|
|
|
|
// [mDic setObject:r.errStr forKey:@"errStr"];
|
|
|
|
// authResult(mDic);
|
|
|
|
|
|
|
|
// NSMutableDictionary *mDic = [[NSMutableDictionary alloc]init];
|
|
|
|
|
|
|
|
// [mDic setObject:[NSString stringWithFormat:@"%@",resp.errStr]] forKey:@"errStr"];
|
|
|
|
// [mDic setObject:[NSString stringWithFormat:@"%d",resp.errCode]] forKey:@"errCode"];
|
|
|
|
// authResult(mDic);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
...
|
...
|
|