Skip to content

Commit

Permalink
fix: fix iOS imageLoader deprecated api
Browse files Browse the repository at this point in the history
  • Loading branch information
huiqiangdev committed Apr 14, 2022
1 parent 4c3e99f commit c538e0c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ios/WechatApi.m
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,12 @@ - (void)shareToWeixinWithData:(NSDictionary *)aData scene:(int)aScene resolver:(
rejecter:(RCTPromiseRejectBlock)reject
{
NSString *imageUrl = aData[RCTWXShareTypeThumbImageUrl];
if (imageUrl.length && self.bridge.imageLoader) {
RCTImageLoader *imageLoader = [self.bridge moduleForClass:[RCTImageLoader class]];

if (imageUrl.length && imageLoader) {
NSURL *url = [NSURL URLWithString:imageUrl];
NSURLRequest *imageRequest = [NSURLRequest requestWithURL:url];
[self.bridge.imageLoader loadImageWithURLRequest:imageRequest size:CGSizeMake(100, 100) scale:1 clipped:FALSE resizeMode:RCTResizeModeStretch progressBlock:nil partialLoadBlock:nil
[imageLoader loadImageWithURLRequest:imageRequest size:CGSizeMake(100, 100) scale:1 clipped:FALSE resizeMode:RCTResizeModeStretch progressBlock:nil partialLoadBlock:nil
completionBlock:^(NSError *error, UIImage *image) {
[self shareToWeixinWithData:aData thumbImage:image scene:aScene resolver:resolve rejecter:reject];
}];
Expand All @@ -487,7 +489,7 @@ - (void)shareToWeixinWithData:(NSDictionary *)aData
rejecter:(RCTPromiseRejectBlock)reject
{
NSString *type = aData[RCTWXShareType];

RCTImageLoader *imageLoader = [self.bridge moduleForClass:[RCTImageLoader class]];
if ([type isEqualToString:RCTWXShareTypeText]) {

} else {
Expand Down Expand Up @@ -554,7 +556,8 @@ - (void)shareToWeixinWithData:(NSDictionary *)aData
[type isEqualToString:RCTWXShareTypeImageResource]) {
NSURL *url = [NSURL URLWithString:aData[RCTWXShareImageUrl]];
NSURLRequest *imageRequest = [NSURLRequest requestWithURL:url];
[self.bridge.imageLoader loadImageWithURLRequest:imageRequest callback:^(NSError *error, UIImage *image) {

[imageLoader loadImageWithURLRequest:imageRequest callback:^(NSError *error, UIImage *image) {
if (image == nil){
reject(@"分享",@"fail to load image resource",nil);
} else {
Expand Down

0 comments on commit c538e0c

Please sign in to comment.