Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions OpenShareDemo/openshare/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ @interface ViewController ()
@implementation ViewController{
NSDictionary *icons;
UIScrollView *panel;
UIImage *testImage,*testThumbImage;
UIImage *testImage,*testThumbImage,*hdImage;
NSData *testGifImage,*testFile;
}

Expand All @@ -30,6 +30,7 @@ - (void)viewDidLoad {
//初始化测试数据
testImage = [UIImage imageNamed:@"Default"];//[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default@2x" ofType:@"png"]];
testThumbImage= [UIImage imageNamed:@"logo"];//[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"logo" ofType:@"png"]];
hdImage = [UIImage imageNamed:@"Default"];
testGifImage= [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"logo" ofType:@"gif"]];
testFile= [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"]];

Expand Down Expand Up @@ -324,7 +325,7 @@ -(UIView*)weixinView:(CGRect)frame{
seg.center=CGPointMake(frame.size.width/2, 20);
[ret addSubview:seg];

NSArray *titles=@[@"发送Text消息",@"发送Photo消息",@"发送Link消息",@"发送Music消息",@"发送Video消息",@"发送App消息",@"发送非gif表情",@"发送gif表情",@"发送文件消息"];
NSArray *titles=@[@"发送Text消息",@"发送Photo消息",@"发送Link消息",@"发送Music消息",@"发送Video消息",@"发送App消息",@"发送非gif表情",@"发送gif表情",@"发送文件消息",@"小程序分享"];
NSArray *fromX=@[@(frame.size.width/4),@(frame.size.width*3/4)];
int fromY=calcYFrom(seg)+ 40;
for (int i=0; i<titles.count;i++ ) {
Expand Down Expand Up @@ -430,6 +431,13 @@ -(void)weixinViewHandler:(UIButton*)btn{
msg.title=@"test.pdf";//添加到收藏的时候,微信会根据文件名打开。fileExt信息丢失。微信的bug
msg.fileExt=@"pdf";
msg.multimediaType=OSMultimediaTypeFile;
}else if (btn.tag==30010) {
//小程序
msg.path=@"/page/xxxx/views/detail/detail";//页面路径
msg.userName=@"请替换自己的微信原始id";
msg.hdImageData=UIImageJPEGRepresentation(hdImage, 1); //小程序高清大图小于128
msg.multimediaType=OSMultimediaTypeNews;
msg.link=@"http://www.baidu.com/";
}


Expand Down
9 changes: 9 additions & 0 deletions openshare/OpenShare+Weixin.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ +(NSString*)genWeixinShareUrl:(OSMessage*)msg to:(int)shareTo{
dic[@"fileData"]= [self dataWithImage:msg.image];
dic[@"thumbData"]=msg.thumbnail ? [self dataWithImage:msg.thumbnail] : [self dataWithImage:msg.image scale:CGSizeMake(100, 100)];
dic[@"objectType"]=@"2";
}else if ([msg isEmpty:nil AndNotEmpty:@[@"userName",@"path",@"hdImageData",@"link"]]) {
//小程序
dic[@"description"]=msg.desc?:msg.title;
dic[@"mediaUrl"]=msg.link;
dic[@"title"] =msg.title;
dic[@"objectType"]=@"36";
dic[@"appBrandUserName"] =msg.userName;
dic[@"appBrandPath"] =msg.path;
dic[@"hdThumbData"]=msg.hdImageData? :[self dataWithImage:msg.image scale:CGSizeMake(260, 210)];
}else if([msg isEmpty:nil AndNotEmpty:@[@"link",@"title",@"image"]]){
//有链接。
dic[@"description"]=msg.desc?:msg.title;
Expand Down
4 changes: 4 additions & 0 deletions openshare/OpenShare.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ typedef enum : NSUInteger {
@property NSString* mediaDataUrl;
@property NSString* fileExt;
@property (nonatomic, strong) NSData *file; /// 微信分享gif/文件
//for 微信小程序
@property (nonatomic, strong) NSString *userName; //原始id
@property (nonatomic, strong) NSString *path; //页面的路径
@property (nonatomic, strong) NSData *hdImageData; //新版本的预览图 128k
/**
* 判断emptyValueForKeys的value都是空的,notEmptyValueForKeys的value都不是空的。
*
Expand Down