1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- //
- // WechatShareTool.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/9/26.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "WechatShareTool.h"
- @implementation WechatShareTool
- + (void)shareImageWithplatformType:(UMSocialPlatformType)platformType withDict:(NSDictionary *)dict {
- //创建分享消息对象
- UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
- //创建图片内容对象
- UMShareImageObject *shareObject = [[UMShareImageObject alloc] init];
- [shareObject setShareImage:[dict objectForKey:@"shareImageUrl"]];
- //分享消息对象设置分享内容对象
- messageObject.shareObject = shareObject;
-
- [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:nil completion:^(id data, NSError *error) {
-
- }];
- }
- + (void)shareURLWithplatformType:(UMSocialPlatformType)platformType withDict:(NSDictionary *)dict {
- //创建分享消息对象
- UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
- //创建图片内容对象
- UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:dict[@"shareTitle"] descr:dict[@"shareDescirpt"] thumImage:dict[@"shareImageUrl"]];
- shareObject.webpageUrl = dict[@"shareUrl"];
- messageObject.shareObject = shareObject;
- [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:nil completion:^(id data, NSError *error) {
-
- }];
- }
- + (void)shareVideoWithplatformType:(UMSocialPlatformType)platformType withDict:(NSDictionary *)dict {
- //创建分享消息对象
- UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
- //创建视频内容对象
- UMShareVideoObject *shareObject = [UMShareVideoObject shareObjectWithTitle:dict[@"shareTitle"] descr:dict[@"shareDescription"] thumImage:dict[@"shareThumb"]];
- //设置视频网页播放地址
- shareObject.videoUrl = dict[@"shareVideoUrl"];
- // shareObject.videoStreamUrl = @"这里设置视频数据流地址(如果有的话,而且也要看所分享的平台支不支持)";
- //分享消息对象设置分享内容对象
- messageObject.shareObject = shareObject;
-
- [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:nil completion:^(id data, NSError *error) {
-
- }];
- }
- + (void)shareMinProgramWithplatformType:(UMSocialPlatformType)platformType withDict:(NSDictionary *)dict {
- //创建分享消息对象
- UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
- UMShareMiniProgramObject *shareObject = [UMShareMiniProgramObject shareObjectWithTitle:dict[@"shareTitle"] descr:dict[@"shareDescription"] thumImage:dict[@"shareThumb"]];
- shareObject.webpageUrl = dict[@"shareUrl"];
- shareObject.userName = dict[@"shareID"];
- shareObject.path = dict[@"sharePath"];
- messageObject.shareObject = shareObject;
- // shareObject.hdImageData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"logo" ofType:@"png"]];
- NSString *minType = dict[@"minType"];
- switch (minType.integerValue) {
- case 1:
- shareObject.miniProgramType = UShareWXMiniProgramTypeRelease; //正式版
- break;
- case 2:
- shareObject.miniProgramType = UShareWXMiniProgramTypeTest; // 开发版
- break;
- case 3:
- shareObject.miniProgramType = UShareWXMiniProgramTypePreview; //体验版
- break;
- default:
- shareObject.miniProgramType = UShareWXMiniProgramTypeRelease; // //线上
- break;
- }
- [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:nil completion:^(id data, NSError *error) {
-
- }];
- }
- @end
|