Commit 5cd0a7e0 authored by 王伟明's avatar 王伟明

Merge branch 'ajp/dev' into 'master'

Ajp/dev

See merge request !7
parents 4868d66a d0466236
...@@ -35,11 +35,12 @@ TODO: Add long description of the pod here. ...@@ -35,11 +35,12 @@ TODO: Add long description of the pod here.
s.dependency 'Weibo_SDK', '3.2.7' s.dependency 'Weibo_SDK', '3.2.7'
s.dependency 'DouyinOpenSDK', '1.4.1' s.dependency 'DouyinOpenSDK', '1.4.1'
s.dependency 'GMKit' s.dependency 'GMKit'
s.dependency 'MBProgressHUD', '0.9.2' s.dependency 'MBProgressHUD'
s.dependency 'GMJSONModel' s.dependency 'GMJSONModel'
s.dependency 'GMPhobos' s.dependency 'GMPhobos'
s.dependency 'GMFoundation' s.dependency 'GMFoundation'
s.dependency 'Masonry' s.dependency 'Masonry'
s.dependency 'GMHud'
s.frameworks = ['Photos'] s.frameworks = ['Photos']
s.pod_target_xcconfig = { 'VALID_ARCHS' => 'arm64 armv7 x86_64' } s.pod_target_xcconfig = { 'VALID_ARCHS' => 'arm64 armv7 x86_64' }
......
...@@ -13,15 +13,18 @@ ...@@ -13,15 +13,18 @@
@class GMShareView; @class GMShareView;
@protocol GMDiaryShareViewDelegate <NSObject> @protocol GMDiaryShareViewDelegate <NSObject>
@optional @optional
/** @brief 定制分享定制内容*/ /// 额外的分享数据内容,业务层可根据需求进行修改
- (NSMutableDictionary *)fetchSharePublishContent:(GMSharePlatform)shareType; /// @param shareType shareType
- (NSDictionary *)extra_shareParams:(GMSharePlatform)shareType;
/** 分享成功 */ /** 分享成功 */
- (void)shareResponseSuccess; - (void)shareResponseSuccess;
/** @brief 分享日记的shareObject*/
- (void)shareObject:(WMShareObject *)object; - (void)shareObject:(WMShareObject *)object;
@end @end
@interface GMDiaryShareView : GMView @interface GMDiaryShareView : GMView
/** @brief 分享日记的shareObject*/
@property (nonatomic, strong) WMShareObject *object;
/** /**
连续签到,补签任务 连续签到,补签任务
*/ */
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "GMDiaryShareView.h" #import "GMDiaryShareView.h"
#import "GMDiaryShareInfoView.h" #import "GMDiaryShareInfoView.h"
#import "WMShareObject.h" #import "WMShareObject.h"
#import "GMShareConstant.h"
#import <MBProgressHUD/MBProgressHUD.h> #import <MBProgressHUD/MBProgressHUD.h>
#import <GMPhobos/Phobos.h> #import <GMPhobos/Phobos.h>
...@@ -117,9 +118,6 @@ ...@@ -117,9 +118,6 @@
[view setShareClickedBlcok:^{ [view setShareClickedBlcok:^{
weakSelf.shareUrl = object.shareData.url; weakSelf.shareUrl = object.shareData.url;
[weakSelf hideShareView]; [weakSelf hideShareView];
if ([weakSelf.delegate respondsToSelector:@selector(shareObject:)]) {
[weakSelf.delegate shareObject:object.shareData];
}
[weakSelf shareWithType:GMSharePlatformWechatTimeline]; [weakSelf shareWithType:GMSharePlatformWechatTimeline];
}]; }];
if (i < diaryArr.count - 1) { if (i < diaryArr.count - 1) {
...@@ -136,41 +134,45 @@ ...@@ -136,41 +134,45 @@
[self toast:@"您未安装微信客户端"]; [self toast:@"您未安装微信客户端"];
return; return;
} }
NSMutableDictionary *shareParams = [NSMutableDictionary dictionaryWithDictionary:[self.object getShareParams:type]];
//获取定制的分享内容 //获取定制的分享内容
NSMutableDictionary *shareParams = [NSMutableDictionary dictionary]; if ([self.delegate respondsToSelector:@selector(extra_shareParams:)]) {
if ([self.delegate respondsToSelector:@selector(fetchSharePublishContent:)]) { NSDictionary *extra_params = [self.delegate extra_shareParams:GMSharePlatformWechatTimeline];
shareParams = [self.delegate fetchSharePublishContent:GMSharePlatformWechatTimeline]; if (extra_params) {
[shareParams addEntriesFromDictionary:extra_params];
}
} }
// 埋点
[self phobosClickShareWithType:type]; [self phobosClickShareWithType:type];
[[GMShareSDK shareInstance] share: type parameters:[shareParams mutableCopy] onStateChanged:^(GMShareResponseState state, NSError *error) { [[GMShareSDK shareInstance] share: type parameters:[shareParams mutableCopy] onStateChanged:^(GMShareResponseState state, NSError *error) {
switch (state) { switch (state) {
case GMShareResponseStateBegin:{ case GMShareResponseStateBegin:{
// debugLog(@"启动分享"); // debugLog(@"启动分享");
break;
} }
break;
case GMShareResponseStateSuccess:{ case GMShareResponseStateSuccess:{
// debugLog(@"分享成功"); // debugLog(@"分享成功");
if (self) { if (self) {
if (self.delegate != nil && ![self.delegate isKindOfClass:[NSNull class]]) { if (self.delegate != nil && ![self.delegate isKindOfClass:[NSNull class]]) {
if ([self.delegate respondsToSelector:@selector(shareResponseSuccess)]) { if ([self.delegate respondsToSelector:@selector(shareResponseSuccess)]) {
[self.delegate shareResponseSuccess]; [self.delegate shareResponseSuccess];
} }
} }
NSDictionary *dic = @{@"page_name": SafeValue(self.pageName),
@"share_channel": _getGMShareChannelByType(type)};
[Phobos track:@"share_success_statistics" attributes:dic];
} }
break;
} }
case GMShareResponseStateFail:{
// debugLog(@"分享失败,错误描述:%@", error);
break; break;
case GMShareResponseStateFail:{
// debugLog(@"分享失败,错误描述:%@", error);
} }
case GMShareResponseStateCancel:{
// debugLog(@"取消分享");
break; break;
case GMShareResponseStateCancel:{
// debugLog(@"取消分享");
} }
break;
default: default:
break; break;
} }
...@@ -184,48 +186,13 @@ ...@@ -184,48 +186,13 @@
NSDictionary *dic = @{@"page_name": SafeValue(phobosView.pageName), NSDictionary *dic = @{@"page_name": SafeValue(phobosView.pageName),
@"business_id": SafeValue(phobosView.businessId), @"business_id": SafeValue(phobosView.businessId),
@"url": SafeValue(self.shareUrl), @"url": SafeValue(self.shareUrl),
@"share_channel": [self channel:type], @"share_channel": _getGMShareChannelByType(type),
@"task_type":@"diary", @"task_type":@"diary",
@"business":@"diary_id" @"business":@"diary_id"};
};
[Phobos track:@"page_click_share_channel" attributes:dic]; [Phobos track:@"page_click_share_channel" attributes:dic];
} }
} }
- (NSString *)channel:(GMSharePlatform)type {
NSString *channel = @"";
switch (type) {
case GMSharePlatformWechatSession:
channel = @"wechat";
break;
case GMSharePlatformWechatTimeline:
channel = @"wechatline";
break;
case GMSharePlatformQQFriend:
channel = @"qq";
break;
case GMSharePlatformQQSpace:
channel = @"qzone";
break;
case GMSharePlatformSinaWeibo:
channel = @"tsina";
break;
case GMSharePlatformWechatSessionSnapShot:
channel = @"wechat_snapshot";
break;
case GMSharePlatformWechatTimelineSnapShot:
channel = @"wechatline_snapshot";
break;
case GMSharePlatformCopyLink:
channel = @"copy_url";
break;
default:
channel = @"";
break;
}
return channel;
}
/** * @brief 分享结果提示*/ /** * @brief 分享结果提示*/
- (void)toast:(NSString *)text{ - (void)toast:(NSString *)text{
[_hud hide:YES]; [_hud hide:YES];
......
...@@ -23,8 +23,9 @@ ...@@ -23,8 +23,9 @@
- (void)willShowShareView:(GMShareView *)shareView; - (void)willShowShareView:(GMShareView *)shareView;
@optional @optional
/** @brief 定制分享定制内容*/ /// 额外的分享数据内容,业务层可根据需求进行修改
- (NSMutableDictionary *)fetchSharePublishContent:(GMSharePlatform)shareType; /// @param shareType shareType
- (NSDictionary *)extra_shareParams:(GMSharePlatform)shareType;
/** @brief 删除*/ /** @brief 删除*/
- (void)deleteContent; - (void)deleteContent;
/** @brief 收藏*/ /** @brief 收藏*/
...@@ -124,7 +125,7 @@ ...@@ -124,7 +125,7 @@
/** /**
* @author wangyang, 16-01-22 19:01:00 * @author wangyang, 16-01-22 19:01:00
* *
* @brief 调用该方法直接分享到指定平台,但仍会走 fetchSharePublishContent 这个代理方法以取得待分享的内容 * @brief 调用该方法直接分享到指定平台
* @param type 将要分享到的平台 * @param type 将要分享到的平台
* @since 5.9.0 * @since 5.9.0
*/ */
......
...@@ -11,27 +11,18 @@ ...@@ -11,27 +11,18 @@
#import <TencentOpenAPI/QQApiInterface.h> #import <TencentOpenAPI/QQApiInterface.h>
#import "GMShareFlowLayout.h" #import "GMShareFlowLayout.h"
#import "DouyinOpenSDKApi.h" #import "DouyinOpenSDKApi.h"
#import "GMShareConstant.h"
#import <WechatOpenSDK/WXApi.h> #import <WechatOpenSDK/WXApi.h>
#import <Weibo_SDK/WeiboSDK.h> #import <Weibo_SDK/WeiboSDK.h>
#import "GMShareVideoAlertView.h" #import "GMShareVideoAlertView.h"
#import <GMShareSDK/GMShareSDK.h> #import <GMShareSDK/GMShareSDK.h>
#import <GMKit/GMButton.h> #import <GMKit/GMButton.h>
#import <GMKit/GMLabel.h> #import <GMKit/GMLabel.h>
#import <GMPhobos/Phobos.h>
#import <GMPhobos/UIResponder+PhobosPV.h>
#import <GMKit/UIColor+GMTheme.h>
#import <GMKit/Constant.h>
#import <GMKit/GMFont.h>
#import <GMKit/Constant.h>
#import <GMKit/UIView+LineWithAutolayout.h>
#import <GMKit/GMCollectionView.h>
#import <GMFoundation/NSString+GM.h>
#import <GMKit/UIView+SafeArea.h>
#import <GMKit/GMSafeValue.h>
#import <GMKit/UIView+Layout.h>
//#import <GMShareSDK/GMShareSDK-umbrella.h>
@import GMKit;
@import GMPhobos;
@import GMFoundation;
//@import GMPhobos; //@import GMPhobos;
static NSString *shareCellIdentifier = @"shareCellIdentifier"; static NSString *shareCellIdentifier = @"shareCellIdentifier";
...@@ -405,12 +396,16 @@ static NSString *shareCellIdentifier = @"shareCellIdentifier"; ...@@ -405,12 +396,16 @@ static NSString *shareCellIdentifier = @"shareCellIdentifier";
} }
- (void)goToShareWithType:(GMSharePlatform)type { - (void)goToShareWithType:(GMSharePlatform)type {
NSMutableDictionary *shareParams = [NSMutableDictionary dictionaryWithDictionary:[self.shareObject getShareParams:type]];
//获取定制的分享内容 //获取定制的分享内容
NSMutableDictionary *shareParams = [NSMutableDictionary dictionary]; if ([self.delegate respondsToSelector:@selector(extra_shareParams:)]) {
if ([self.delegate respondsToSelector:@selector(fetchSharePublishContent:)]) { NSDictionary *extra_params = [self.delegate extra_shareParams:GMSharePlatformWechatTimeline];
shareParams = [self.delegate fetchSharePublishContent:type]; if (extra_params) {
[shareParams addEntriesFromDictionary:extra_params];
}
} }
// 埋点
[self phobosClickShareWithType:type]; [self phobosClickShareWithType:type];
[[GMShareSDK shareInstance] share: type parameters:[shareParams mutableCopy] onStateChanged:^(GMShareResponseState state, NSError *error) { [[GMShareSDK shareInstance] share: type parameters:[shareParams mutableCopy] onStateChanged:^(GMShareResponseState state, NSError *error) {
...@@ -431,7 +426,7 @@ static NSString *shareCellIdentifier = @"shareCellIdentifier"; ...@@ -431,7 +426,7 @@ static NSString *shareCellIdentifier = @"shareCellIdentifier";
if ([self.delegate isKindOfClass:[UIResponder class]] && self.isReportShareResult) { if ([self.delegate isKindOfClass:[UIResponder class]] && self.isReportShareResult) {
UIResponder *phobosView = (UIResponder *)self.delegate; UIResponder *phobosView = (UIResponder *)self.delegate;
NSDictionary *dic = @{@"page_name": SafeValue(phobosView.pageName), NSDictionary *dic = @{@"page_name": SafeValue(phobosView.pageName),
@"share_channel": [self channel:type]}; @"share_channel": _getGMShareChannelByType(type)};
[Phobos track:@"share_success_statistics" attributes:dic]; [Phobos track:@"share_success_statistics" attributes:dic];
} }
break; break;
...@@ -450,47 +445,6 @@ static NSString *shareCellIdentifier = @"shareCellIdentifier"; ...@@ -450,47 +445,6 @@ static NSString *shareCellIdentifier = @"shareCellIdentifier";
}]; }];
} }
- (NSString *)channel:(GMSharePlatform)type {
NSString *channel = @"";
switch (type) {
case GMSharePlatformWechatSession:
channel = @"wechat";
break;
case GMSharePlatformWechatTimeline:
channel = @"wechatline";
break;
case GMSharePlatformQQFriend:
channel = @"qq";
break;
case GMSharePlatformQQSpace:
channel = @"qzone";
break;
case GMSharePlatformSinaWeibo:
channel = @"tsina";
break;
case GMSharePlatformWechatSessionSnapShot:
channel = @"wechat_snapshot";
break;
case GMSharePlatformWechatTimelineSnapShot:
channel = @"wechatline_snapshot";
break;
case GMSharePlatformCopyLink:
channel = @"copy_url";
break;
case GMSharePlatformDouyin:
channel = @"douyin";
break;
default:
channel = @"";
break;
}
return channel;
}
- (void)dealloc {
}
/** /**
* @brief 分享界面的有关动画 * @brief 分享界面的有关动画
添加上滑动画 添加上滑动画
...@@ -569,7 +523,7 @@ static NSString *shareCellIdentifier = @"shareCellIdentifier"; ...@@ -569,7 +523,7 @@ static NSString *shareCellIdentifier = @"shareCellIdentifier";
NSDictionary *dic = @{@"page_name": SafeString(pageName), NSDictionary *dic = @{@"page_name": SafeString(pageName),
@"business_id": SafeString(businessId), @"business_id": SafeString(businessId),
@"url": SafeString(self.shareUrl), @"url": SafeString(self.shareUrl),
@"share_channel": [self channel:type], @"share_channel": _getGMShareChannelByType(type),
@"task_type":SafeString(self.taskType), @"task_type":SafeString(self.taskType),
@"business":@"channel"}; @"business":@"channel"};
[Phobos track:@"page_click_share_channel" attributes:dic]; [Phobos track:@"page_click_share_channel" attributes:dic];
......
//
// WMWeixinShareView.h
// Gengmei
//
// Created by Sean Lee on 7/6/15.
// Copyright (c) 2015 Wanmeichuangyi. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "WMShareObject.h"
#import "GMShareConstant.h"
@interface GMWeixinShareView : UIView
@property (nonatomic, strong) WMShareObject *weixinShareObject;
/// shareBlock
@property (nonatomic, copy) GMSharePlatformClick platformClick;
/**
* @author licong, 16-01-08 14:01:38
*
* 实例化一个WMWeixinShareView
*
* @return 返回一个实例化成功的shareView
*
* @since 5.8.0
*/
+ (GMWeixinShareView *)shareView;
/**
* @author licong, 16-01-08 14:01:46
*
* 弹出微信分享框
*
* @since 5.8.0
*/
- (void)showShareView:(id)sender;
/**
* @author licong, 16-01-08 14:01:46
*
* 隐藏微信分享框
*
* @since 5.8.0
*/
- (IBAction)hideShareView:(id)sender;
@end
//
// WMWeixinShareView.m
// Gengmei
//
// Created by Sean Lee on 7/6/15.
// Copyright (c) 2015 Wanmeichuangyi. All rights reserved.
//
#import "GMWeixinShareView.h"
#import "NSMutableDictionary+GMShareSDK.h"
#import "GMShareSDK.h"
#import "GMShareConstant.h"
@import GMPhobos;
@import GMKit;
@import GMFoundation;
@interface GMWeixinShareView ()
@property (weak, nonatomic) IBOutlet UITapGestureRecognizer *tapGestureRecognizer;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *shareViewBottomConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *shareViewHeight;
@end
@implementation GMWeixinShareView
+ (GMWeixinShareView *)shareView{
GMWeixinShareView *shareView = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([GMWeixinShareView class]) owner:nil options:nil].firstObject;
shareView.shareViewHeight.constant = UIDevice.aspectRatioType == GMDeviceAspectRatioTypeWide ? 184 : 150;
return shareView;
}
- (IBAction)shareButtonClicked:(UIButton *)button{
[self hideShareView:nil];
GMSharePlatform type = (GMSharePlatform)button.tag;
//分享埋点
[self weixin_click_share_channel:type];
if (self.platformClick) {
self.platformClick(type);
}
}
- (void)showShareView:(id)sender {
self.hidden = NO;
self.tapGestureRecognizer.enabled = YES;
[UIView animateWithDuration:0.25 animations:^{
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
self.shareViewBottomConstraint.constant = [UIDevice aspectRatioType] == GMDeviceAspectRatioTypeWide ? 184 : 150;
[self layoutIfNeeded];
}];
}
- (IBAction)hideShareView:(id)sender {
self.tapGestureRecognizer.enabled = NO;
[UIView animateWithDuration:0.25 animations:^{
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
self.shareViewBottomConstraint.constant = 0;
[self layoutIfNeeded];
} completion:^(BOOL finished) {
self.hidden = YES;
}];
}
//埋点
- (void)weixin_click_share_channel:(NSInteger)type {
//type 3-微信好友, 4-朋友圈
[Phobos track:@"weixin_click_share_channel" attributes:@{
@"share_channel" : type == 3 ? @"微信好友" : @"朋友圈",
@"from" : self.weixinShareObject.from.isNonEmpty ? self.weixinShareObject.from : @""}];
}
@end
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// Copyright (c) 2015 Wanmeichuangyi. All rights reserved. // Copyright (c) 2015 Wanmeichuangyi. All rights reserved.
// //
#import "GMShareBaseObject.h" #import "GMShareBaseObject.h"
//#import <GMBase/GMObject.h> #import "GMThirdPartyDefine.h"
@protocol WMShareBasicObject @end @protocol WMShareBasicObject @end
@interface WMShareBasicObject : GMShareBaseObject @interface WMShareBasicObject : GMShareBaseObject
...@@ -22,6 +22,31 @@ ...@@ -22,6 +22,31 @@
@property (nonatomic,strong) NSString * path; @property (nonatomic,strong) NSString * path;
@property (nonatomic,strong) NSString * userName; @property (nonatomic,strong) NSString * userName;
@property (nonatomic,strong) NSString * thumbImageUrl; @property (nonatomic,strong) NSString * thumbImageUrl;
@property (nonatomic,strong) UIImage *hdImage;
@property (nonatomic,strong) UIImage *thumbImage;
@end
@protocol GMCoverObject @end
@interface GMCoverObject : GMShareBaseObject
@property (nonatomic,strong) NSString * desc;
@property (nonatomic,strong) NSString * image;
@end
@protocol GMOthersObject @end
@interface GMOthersObject : GMShareBaseObject
@property (nonatomic,strong) NSString * cityName;
@property (nonatomic,strong) NSArray<GMCoverObject> * cover;
@property (nonatomic,strong) NSString * title;
@property (nonatomic,strong) NSString * type;
@property (nonatomic,strong) NSString * path;
@property (nonatomic,strong) NSString * voteNum;
@property (nonatomic,strong) NSString * voteNumDesc;
@property (nonatomic,strong) NSString * beforeDesc;
@property (nonatomic,strong) NSString * afterCoverUrl;
@property (nonatomic,strong) NSString * afterDesc;
@property (nonatomic,strong) NSString * beforeCoverUrl;
@property (nonatomic,strong) UIImage *afterCoverImage;
@property (nonatomic,strong) UIImage *beforeCoverImage;
@end @end
...@@ -42,11 +67,17 @@ ...@@ -42,11 +67,17 @@
@property (nonatomic,strong) WMShareBasicObject <WMShareBasicObject>* weibo; @property (nonatomic,strong) WMShareBasicObject <WMShareBasicObject>* weibo;
@property (nonatomic,strong) GMWechatminiObject <GMWechatminiObject>* wechatmini; @property (nonatomic,strong) GMWechatminiObject <GMWechatminiObject>* wechatmini;
@property (nonatomic,strong) WMShareBasicObject <WMShareBasicObject>* douyin; // 分享到抖音 扫脸1.5 @property (nonatomic,strong) WMShareBasicObject <WMShareBasicObject>* douyin; // 分享到抖音 扫脸1.5
@property (nonatomic,strong) GMOthersObject <GMWechatminiObject>* others;
@property (nonatomic, copy) NSString *page_name;// 埋点使用 @property (nonatomic, copy) NSString *page_name;// 埋点使用
@property (nonatomic, copy) NSString *business_id;// 埋点使用 @property (nonatomic, copy) NSString *business_id;// 埋点使用
@property (nonatomic, copy) NSString *is_like;//埋点使用 @property (nonatomic, copy) NSString *is_like;//埋点使用
@property (nonatomic, copy) NSString *videoUrl;//视频URL(分享视频时)扫脸1.5 @property (nonatomic, copy) NSString *videoUrl;//视频URL(分享视频时)扫脸1.5
@property (nonatomic, assign) GMShareContentType contentType;
@property (nonatomic, strong) UIImage *shareImage;
@property (nonatomic, assign) GMSharePlatform platform;/// 分享平台
/// 获取分享通用数据
/// @param shareType shareType
- (NSMutableDictionary *)getShareParams:(GMSharePlatform)shareType;
@end @end
@protocol GMDiaryShareObject @end @protocol GMDiaryShareObject @end
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
// //
#import "WMShareObject.h" #import "WMShareObject.h"
#import "NSMutableDictionary+GMShareSDK.h"
@import GMFoundation;
@import SDWebImage;
@implementation WMShareBasicObject @implementation WMShareBasicObject
...@@ -16,11 +18,167 @@ ...@@ -16,11 +18,167 @@
@implementation GMWechatminiObject @implementation GMWechatminiObject
// 获取到图片地址后,进行优先图片下载
- (void)setHdImageUrl:(NSString *)hdImageUrl {
_hdImageUrl = hdImageUrl;
self.thumbImage = [UIImage imageNamed:@"icon"];
if (hdImageUrl.length) {
__weak typeof(self) weakSelf = self;
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:hdImageUrl] completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
if (image) {
weakSelf.hdImage = image;
}
}];
}
}
- (void)setThumbImageUrl:(NSString *)thumbImageUrl {
_thumbImageUrl = thumbImageUrl;
self.thumbImage = [UIImage imageNamed:@"share_smallProgram"];
if (thumbImageUrl.length) {
__weak typeof(self) weakSelf = self;
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:thumbImageUrl] completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
if (image) {
weakSelf.thumbImage = image;
}
}];
}
}
@end @end
@implementation GMCoverObject
@end
@implementation GMOthersObject
- (void)setAfterCoverUrl:(NSString *)afterCoverUrl {
_afterCoverUrl = afterCoverUrl;
if (!afterCoverUrl.isNonEmpty) {
return;
}
__weak typeof(self) weakSelf = self;
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:afterCoverUrl] completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
if (image) {
weakSelf.afterCoverImage = image;
}
}];
}
- (void)setBeforeCoverUrl:(NSString *)beforeCoverUrl {
_beforeCoverUrl = beforeCoverUrl;
if (!beforeCoverUrl.isNonEmpty) {
return;
}
__weak typeof(self) weakSelf = self;
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:beforeCoverUrl] completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
if (image) {
weakSelf.beforeCoverImage = image;
}
}];
}
@end
@implementation WMShareObject @implementation WMShareObject
- (void)setImage:(NSString *)image {
_image = image;
if (image.length) {
__weak typeof(self) weakSelf = self;
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:image] completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
if (image) {
weakSelf.shareImage = image;
}
}];
}
}
- (void)setPlatform:(GMSharePlatform)platform {
_platform = platform;
switch (platform) {
case GMSharePlatformWechatSessionSnapShot:
case GMSharePlatformWechatTimelineSnapShot:
{
self.shareImage = self.wechatScreenshot.content;
self.contentType = GMShareContentTypeImage;
}
break;
default:
{
self.contentType = GMShareContentTypeAuto;
}
break;
}
}
/// 获取分享通用数据
/// @param shareType 分享平台
- (NSMutableDictionary *)getShareParams:(GMSharePlatform)shareType {
self.platform = shareType;
WMShareBasicObject *object = nil;
UIImage *shareImage = self.shareImage?:[UIImage imageNamed:@"icon"];
// 微信会话分享且微信小程序内容不为空的时候,认为是微信小程序分享
if (shareType == GMSharePlatformWechatSession && self.wechatmini.path.length) {
shareType = GMSharePlatformWechatMiniProgram;
}
switch (shareType) {
case GMSharePlatformWechatSession:
object = self.wechat;
break;
case GMSharePlatformWechatTimeline:
object = self.wechatline;
break;
case GMSharePlatformWechatMiniProgram:
object = self.wechatmini;
break;
case GMSharePlatformQQFriend:
object = self.qq;
break;
case GMSharePlatformQQSpace:
object = self.qqzone;
break;
case GMSharePlatformSinaWeibo:
object = self.weibo;
break;
case GMSharePlatformDouyin:
object = self.douyin;
break;
case GMSharePlatformWechatSessionSnapShot:
object = self.wechatScreenshot;
shareImage = self.wechatScreenshot.content;
break;
case GMSharePlatformWechatTimelineSnapShot:
object = self.wechatlineScreenshot;
shareImage = self.wechatlineScreenshot.content;
break;
default:
break;
}
NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
if (shareType == GMSharePlatformWechatMiniProgram) {
[shareParams shareSetupMiniProgramShareParamsByUrl:self.url
userName:self.wechatmini.userName
path:self.wechatmini.path
title:self.wechatmini.title
description:self.wechatmini.desc
thumbImage:self.wechatmini.thumbImage
hdImageData:self.wechatmini.hdImage];
} else {
if (self.videoUrl.length) {
// 分享视频
[shareParams shareSetupShareParamsByText:object.content images:shareImage url:[NSURL URLWithString:self.url] title:object.title videoUrl:[NSURL URLWithString:self.videoUrl] type:self.contentType];
} else {
[shareParams shareSetupShareParamsByText:object.content
images:shareImage
url:[NSURL URLWithString:self.url]
title:object.title
type:self.contentType];
}
}
return shareParams;
}
@end @end
@implementation GMDiaryShareObject @implementation GMDiaryShareObject
......
//
// GMShareConstant.h
// GMShareSDK
//
// Created by Mikasa on 2021/1/15.
//
#import "GMThirdPartyDefine.h"
typedef void(^GMSharePlatformClick)(GMSharePlatform platform);
extern NSString * const ShareContentType;
extern NSString * const ShareOnlyImage;
extern NSString * const ShareImage;
extern NSString * const ShareUrl;
extern NSString * const ShareTitle;
extern NSString * const ShareText;
extern NSString * const ShareUserName;
extern NSString * const SharePath;
extern NSString * const ShareHdImageData;
extern NSString * const ShareDescription;
extern NSString * const ShareThumbImage;
extern NSString * const ShareVideoUrl;
// 获取分享平台渠道---埋点使用
static inline NSString *_getGMShareChannelByType(GMSharePlatform platformType) {
if (platformType == GMSharePlatformQQFriend) return @"qq";
if (platformType == GMSharePlatformQQSpace) return @"qzone";
if (platformType == GMSharePlatformWechatSession) return @"wechat";
if (platformType == GMSharePlatformWechatTimeline) return @"wechatline";
if (platformType == GMSharePlatformWechatSessionSnapShot) return @"wechat_snapshot";
if (platformType == GMSharePlatformWechatTimelineSnapShot) return @"wechatline_snapshot";
if (platformType == GMSharePlatformWechatMiniProgram) return @"xcx";
if (platformType == GMSharePlatformSinaWeibo) return @"tsina";
if (platformType == GMSharePlatformDouyin) return @"Douyin";
if (platformType == GMSharePlatformCopyLink) return @"copy_url";
return @"Default";
}
//
// GMShareConstant.m
// GMShareSDK
//
// Created by Mikasa on 2021/1/15.
//
NSString * const ShareContentType = @"type";
NSString * const ShareOnlyImage = @"onlyImage";
NSString * const ShareImage = @"image";
NSString * const ShareUrl = @"url";
NSString * const ShareTitle = @"title";
NSString * const ShareText = @"text";
NSString * const ShareUserName = @"userName";
NSString * const SharePath = @"path";
NSString * const ShareHdImageData = @"hdImageData";
NSString * const ShareDescription = @"description";
NSString * const ShareThumbImage = @"thumbImage";
NSString * const ShareVideoUrl = @"videoUrl";
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
* 分享内容状态变更回调处理器 * 分享内容状态变更回调处理器
* *
* @param state 状态 * @param state 状态
* @param userData 附加数据, 返回状态以外的一些数据描述,如:邮件分享取消时,标识是否保存草稿等
* @param error 错误信息,当且仅当state为SSDKResponseStateFail时返回 * @param error 错误信息,当且仅当state为SSDKResponseStateFail时返回
*/ */
typedef void(^GMSDKShareStateChangedHandler) (GMShareResponseState state, NSError *error); typedef void(^GMSDKShareStateChangedHandler) (GMShareResponseState state, NSError *error);
...@@ -25,12 +24,8 @@ typedef void(^GMSDKShareStateChangedHandler) (GMShareResponseState state, NSErr ...@@ -25,12 +24,8 @@ typedef void(^GMSDKShareStateChangedHandler) (GMShareResponseState state, NSErr
/** 判断微博、微信、QQ是否已经安装*/ /** 判断微博、微信、QQ是否已经安装*/
+ (BOOL)isClientInstalled:(GMSharePlatform)platformType; + (BOOL)isClientInstalled:(GMSharePlatform)platformType;
+ (UIImage *)compressWithUrl:(NSString *)url;
+ (UIImage *)compressImage:(UIImage *)image; + (UIImage *)compressImage:(UIImage *)image;
+ (NSString *)shareChannel:(GMSharePlatform)platformType;
- (void)share:(GMSharePlatform)platformType - (void)share:(GMSharePlatform)platformType
parameters:(NSMutableDictionary *)parameters parameters:(NSMutableDictionary *)parameters
onStateChanged:(GMSDKShareStateChangedHandler)stateChangedHandler; onStateChanged:(GMSDKShareStateChangedHandler)stateChangedHandler;
......
This diff is collapsed.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// Created by licong on 2017/8/18. // Created by licong on 2017/8/18.
// Copyright © 2017年 更美互动信息科技有限公司. All rights reserved. // Copyright © 2017年 更美互动信息科技有限公司. All rights reserved.
// //
#import "GMShareConstant.h"
#import "NSMutableDictionary+GMShareSDK.h" #import "NSMutableDictionary+GMShareSDK.h"
#import <WechatOpenSDK/WXApiObject.h> #import <WechatOpenSDK/WXApiObject.h>
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
url:(NSURL *)url url:(NSURL *)url
title:(NSString *)title title:(NSString *)title
type:(GMShareContentType)type{ type:(GMShareContentType)type{
self[@"text"] = text; self[ShareText] = text;
self[@"images"] = images; self[ShareImage] = images;
self[@"url"] = url; self[ShareUrl] = url;
self[@"title"] = title; self[ShareTitle] = title;
self[@"type"] = @(type); self[ShareContentType] = @(type);
} }
- (void)shareSetupShareParamsByText:(NSString *)text - (void)shareSetupShareParamsByText:(NSString *)text
...@@ -29,12 +29,12 @@ ...@@ -29,12 +29,12 @@
title:(NSString *)title title:(NSString *)title
videoUrl:(NSURL *)videoUrl videoUrl:(NSURL *)videoUrl
type:(GMShareContentType)type { type:(GMShareContentType)type {
self[@"text"] = text; self[ShareText] = text;
self[@"images"] = images; self[ShareImage] = images;
self[@"url"] = url; self[ShareUrl] = url;
self[@"title"] = title; self[ShareTitle] = title;
self[@"type"] = @(type); self[ShareContentType] = @(type);
self[@"videoUrl"] = videoUrl; self[ShareVideoUrl] = videoUrl;
} }
- (void)shareSetupMiniProgramShareParamsByUrl:(NSString *)url - (void)shareSetupMiniProgramShareParamsByUrl:(NSString *)url
...@@ -44,14 +44,14 @@ ...@@ -44,14 +44,14 @@
description:(NSString *)description description:(NSString *)description
thumbImage:(id)thumbImage thumbImage:(id)thumbImage
hdImageData:(id)hdImageData{ hdImageData:(id)hdImageData{
self[@"url"] = url; self[ShareUrl] = url;
self[@"userName"] = userName; self[ShareUserName] = userName;
self[@"path"] = path; self[SharePath] = path;
self[@"title"] = title; self[ShareTitle] = title;
self[@"description"] = description; self[ShareDescription] = description;
self[@"thumbImage"] = thumbImage; self[ShareThumbImage] = thumbImage;
self[@"hdImageData"] = hdImageData; self[ShareHdImageData] = hdImageData;
self[@"type"] = @(GMShareContentTypeMiniProgram); self[ShareContentType] = @(GMShareContentTypeMiniProgram);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment