ShareSDK 集成文档 http://wiki.sharesdk.cn/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E6%8C%87%E5%8D%97/
注意点:
1.配置ShareSDK的appkey和appSecret时,安卓的和iOS的可以用同一个
[ShareSDK connectTencentWeiboWithAppKey:@"302147650"
appSecret:@"ae54f4rerer6e1c232423b543569fdfdfdff5c"
redirectUri:@"http://www.sharesdk.cn"
wbApiCls:[WeiboApi class]];
2.QQ和QQ空间的appkey是用同一个
3.在mob上创建应用时,iOS和安卓要分开创建
4. [container setIPadContainerWithView:sender arrowDirect:UIPopoverArrowDirectionUp];
如果没有做iPad的话,可以不用添加这一句
5.集成文档中的第六步一定要认真做
6.实现回调,因为之前接入了腾讯登录的SDK,所以在回调函数中需要实现两个回调函数。(跳客户端需要处理客户端回调,像微信,QQ,如果不加的话,那么回调不能返回成功,只能返回取消)
解决方法1:判断url的前缀,每个SDK的前缀是独一无二的,可以打印url获取
参考代码:
NSString *string = [url absoluteString];
if ([string hasPrefix:@"ShareSDKurl的前缀"]) {
return [ShareSDK handleOpenURL:url sourceApplication:sourceApplication annotation:annotation wxDelegate:self];
} else if ([string hasPrefix:@"腾讯url的前缀"]) {
return [TencentOAuth HandleOpenURL:url];
}
解决方法2:因为我们在使用到ShareSDK的分享时,也包括QQ好友分享,和QQ空间分享,它们的url的前缀跟腾讯登录SDK的url的前缀是一样的,所以我们采用了本地判断的方法解决了这一问题。
参考代码:在初始化QQ登录时将[[MobShare shareMobShare] handleType] 置为 HANDLE_QQLOGIN, 在初始化ShareSDK时将[[MobShare shareMobShare] handleType] 置为 HANDLE_SHARE,其中HANDLE_QQLOGIN和HANDLE_SHARE为枚举
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
int type = [[MobShare shareMobShare] handleType];
if (type == HANDLE_QQLOGIN) {
return [TencentOAuth HandleOpenURL:url];
} else if (type == HANDLE_SHARE) {
return [ShareSDK handleOpenURL:url sourceApplication:sourceApplication annotation:annotation wxDelegate:self];
} else {
return YES;
}
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
int type = [[MobShare shareMobShare] handleType];
if (type == HANDLE_QQLOGIN) {
return [TencentOAuth HandleOpenURL:url];
} else if (type == HANDLE_SHARE) {
return [ShareSDK handleOpenURL:url wxDelegate:self];
} else {
return YES;
}
}
7.微信平台初始化
[ShareSDK connectWeChatWithAppId: @"wx4868b35061f87885"
appSecret: @"64020361b8ec4c99936c0e3999a9f249"
wechatCls: [WXApi class]];
这个初始化是微信总的初始化,初始化完成后,微信好友,微信朋友圈,微信收藏就都开启了,也就是在分享菜单那里就都有了图标显示了。
当然也可以分开初始化微信的这三个平台
微信好友:
[ShareSDK connectWeChatSessionWithAppId: @"wx4868b35061f87885"
appSecret: @"64020361b8ec4c99936c0e3999a9f249"
wechatCls: [WXApi class]];
微信朋友圈:
[ShareSDK connectWeChatTimelineWithAppId: @"wx4868b35061f87885"
appSecret: @"64020361b8ec4c99936c0e3999a9f249"
wechatCls: [WXApi class]];
微信收藏:
[ShareSDK connectWeChatFavWithAppId: @"wx4868b35061f87885"
appSecret: @"64020361b8ec4c99936c0e3999a9f249"
wechatCls: [WXApi class]];
8.[ShareSDK connectWeChatSessionWithAppId:WXAppid wechatCls:[WXApi class]];
[ShareSDK connectWeChatSessionWithAppId:WXAppid appSecret:WXSec wechatCls:[WXApi class]];
这两种初始化方法的区别: 第一个只能分享,第二个可以做分享和登录的功能
9.id
allowCallback:YES
authViewStyle:SSAuthViewStyleFullScreenPopup
viewDelegate:nil
authManagerViewDelegate:_appDelegate.viewDelegate];
其中_appDelegate.viewDelegate是用来修改UI的委托,可以传入nil
10.初始化分享内容
id<ISSContent> publishContent = [ShareSDK content:CONTENT
defaultContent:@""
image:[ShareSDK imageWithPath:imagePath]
title:NSLocalizedString(@"TEXT_HELLO_QZONE", @"Hello QQ空间")
url:@"http://www.mob.com"
description:nil
mediaType:SSPublishContentMediaTypeText];
在初始化分享内容时,如果只分享文字的话 mediaType:SSPublishContentMediaTypeText
如果需要分享文字和图片:mediaType:SSPublishContentMediaTypeNews
11.初始化分享内容时: content是分享的内容,description是内容的描述,defaultContent是默认的分享内容,有的平台是显示content,有的平台是显示description
可以把content,description,defaultContent都填上,该显示哪个就显示哪个。
(腾讯微博显示的是content,QQ空间和QQ好友显示的是description)
12.可以自定制UI,各个平台单独初始化 (12点和13点都是在ShareSDK Demo中的AGApiViewController类中)
)
几个主要平台的初始化方法:
/**
* @brief 分享到新浪微博
*
* @param sender 事件对象
*/
- (void)shareToSinaWeiboClickHandler:(UIButton *)sender
{
//创建分享内容
NSString *imagePath = [[NSBundle mainBundle] pathForResource:IMAGE_NAME ofType:IMAGE_EXT];
id<ISSContent> publishContent = [ShareSDK content:CONTENT
defaultContent:@""
image:[ShareSDK imageWithPath:imagePath]
title:nil
url:nil
description:nil
mediaType:SSPublishContentMediaTypeText];
//创建弹出菜单容器
id<ISSContainer> container = [ShareSDK container];
[container setIPadContainerWithView:sender arrowDirect:UIPopoverArrowDirectionUp];
id<ISSAuthOptions> authOptions = [ShareSDK authOptionsWithAutoAuth:YES
allowCallback:YES
authViewStyle:SSAuthViewStyleFullScreenPopup
viewDelegate:nil
authManagerViewDelegate:_appDelegate.viewDelegate];
//在授权页面中添加关注官方微博
[authOptions setFollowAccounts:[NSDictionary dictionaryWithObjectsAndKeys:
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeSinaWeibo),
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeTencentWeibo),
nil]];
//显示分享菜单
[ShareSDK showShareViewWithType:ShareTypeSinaWeibo
container:container
content:publishContent
statusBarTips:YES
authOptions:authOptions
shareOptions:[ShareSDK defaultShareOptionsWithTitle:nil
oneKeyShareList:[NSArray defaultOneKeyShareList]
qqButtonHidden:NO
wxSessionButtonHidden:NO
wxTimelineButtonHidden:NO
showKeyboardOnAppear:NO
shareViewDelegate:_appDelegate.viewDelegate
friendsViewDelegate:_appDelegate.viewDelegate
picViewerViewDelegate:nil]
result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
if (state == SSPublishContentStateSuccess)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_SUC", @"发表成功"));
}
else if (state == SSPublishContentStateFail)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_FAI", @"发布失败!error code == %d, error code == %@"), [error errorCode], [error errorDescription]);
}
}];
}
/**
* @brief 分享到腾讯微博
*
* @param sender 事件对象
*/
- (void)shareToTencentWeiboClickHandler:(UIButton *)sender
{
//创建分享内容
NSString *imagePath = [[NSBundle mainBundle] pathForResource:IMAGE_NAME ofType:IMAGE_EXT];
id<ISSContent> publishContent = [ShareSDK content:CONTENT
defaultContent:@""
image:[ShareSDK imageWithPath:imagePath]
title:nil
url:nil
description:nil
mediaType:SSPublishContentMediaTypeText];
//创建弹出菜单容器
id<ISSContainer> container = [ShareSDK container];
[container setIPadContainerWithView:sender arrowDirect:UIPopoverArrowDirectionUp];
id<ISSAuthOptions> authOptions = [ShareSDK authOptionsWithAutoAuth:YES
allowCallback:YES
authViewStyle:SSAuthViewStyleFullScreenPopup
viewDelegate:nil
authManagerViewDelegate:_appDelegate.viewDelegate];
//在授权页面中添加关注官方微博
[authOptions setFollowAccounts:[NSDictionary dictionaryWithObjectsAndKeys:
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeSinaWeibo),
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeTencentWeibo),
nil]];
//显示分享菜单
[ShareSDK showShareViewWithType:ShareTypeTencentWeibo
container:container
content:publishContent
statusBarTips:YES
authOptions:authOptions
shareOptions:[ShareSDK defaultShareOptionsWithTitle:nil
oneKeyShareList:[NSArray defaultOneKeyShareList]
qqButtonHidden:NO
wxSessionButtonHidden:NO
wxTimelineButtonHidden:NO
showKeyboardOnAppear:NO
shareViewDelegate:_appDelegate.viewDelegate
friendsViewDelegate:_appDelegate.viewDelegate
picViewerViewDelegate:nil]
result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
if (state == SSPublishContentStateSuccess)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_SUC", @"发表成功"));
}
else if (state == SSPublishContentStateFail)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_FAI", @"发布失败!error code == %d, error code == %@") , [error errorCode], [error errorDescription]);
}
}];
}
/**
* @brief 分享给QQ好友
*
* @param sender 事件对象
*/
- (void)shareToQQFriendClickHandler:(UIButton *)sender
{
//创建分享内容
NSString *imagePath = [[NSBundle mainBundle] pathForResource:IMAGE_NAME ofType:IMAGE_EXT];
id<ISSContent> publishContent = [ShareSDK content:CONTENT
defaultContent:@""
image:[ShareSDK imageWithPath:imagePath]
title:@"ShareSDK"
url:@"http://www.mob.com"
description:nil
mediaType:SSPublishContentMediaTypeNews];
id<ISSAuthOptions> authOptions = [ShareSDK authOptionsWithAutoAuth:YES
allowCallback:YES
authViewStyle:SSAuthViewStyleFullScreenPopup
viewDelegate:nil
authManagerViewDelegate:_appDelegate.viewDelegate];
//在授权页面中添加关注官方微博
[authOptions setFollowAccounts:[NSDictionary dictionaryWithObjectsAndKeys:
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeSinaWeibo),
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeTencentWeibo),
nil]];
//显示分享菜单
[ShareSDK showShareViewWithType:ShareTypeQQ
container:nil
content:publishContent
statusBarTips:YES
authOptions:authOptions
shareOptions:[ShareSDK defaultShareOptionsWithTitle:nil
oneKeyShareList:[NSArray defaultOneKeyShareList]
qqButtonHidden:NO
wxSessionButtonHidden:NO
wxTimelineButtonHidden:NO
showKeyboardOnAppear:NO
shareViewDelegate:_appDelegate.viewDelegate
friendsViewDelegate:_appDelegate.viewDelegate
picViewerViewDelegate:nil]
result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
if (state == SSPublishContentStateSuccess)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_SUC", @"发表成功"));
}
else if (state == SSPublishContentStateFail)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_FAI", @"发布失败!error code == %d, error code == %@"), [error errorCode], [error errorDescription]);
}
}];
}
/**
* @brief 分享到QQ空间
*
* @param sender 事件对象
*/
- (void)shareToQQSpaceClickHandler:(UIButton *)sender
{
//创建分享内容
NSString *imagePath = [[NSBundle mainBundle] pathForResource:IMAGE_NAME ofType:IMAGE_EXT];
id<ISSContent> publishContent = [ShareSDK content:CONTENT
defaultContent:@""
image:[ShareSDK imageWithPath:imagePath]
title:NSLocalizedString(@"TEXT_HELLO_QZONE", @"Hello QQ空间")
url:@"http://www.mob.com"
description:nil
mediaType:SSPublishContentMediaTypeText];
//创建弹出菜单容器
id<ISSContainer> container = [ShareSDK container];
[container setIPadContainerWithView:sender arrowDirect:UIPopoverArrowDirectionUp];
id<ISSAuthOptions> authOptions = [ShareSDK authOptionsWithAutoAuth:YES
allowCallback:YES
authViewStyle:SSAuthViewStyleFullScreenPopup
viewDelegate:nil
authManagerViewDelegate:_appDelegate.viewDelegate];
//在授权页面中添加关注官方微博
[authOptions setFollowAccounts:[NSDictionary dictionaryWithObjectsAndKeys:
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeSinaWeibo),
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeTencentWeibo),
nil]];
//显示分享菜单
[ShareSDK showShareViewWithType:ShareTypeQQSpace
container:container
content:publishContent
statusBarTips:YES
authOptions:authOptions
shareOptions:[ShareSDK defaultShareOptionsWithTitle:nil
oneKeyShareList:[NSArray defaultOneKeyShareList]
qqButtonHidden:NO
wxSessionButtonHidden:NO
wxTimelineButtonHidden:NO
showKeyboardOnAppear:NO
shareViewDelegate:_appDelegate.viewDelegate
friendsViewDelegate:_appDelegate.viewDelegate
picViewerViewDelegate:nil]
result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
if (state == SSPublishContentStateSuccess)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_SUC", @"发表成功"));
}
else if (state == SSPublishContentStateFail)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_FAI", @"发布失败!error code == %d, error code == %@"), [error errorCode], [error errorDescription]);
}
}];
}
/**
* @brief 分享给微信好友
*
* @param sender 事件对象
*/
- (void)shareToWeixinSessionClickHandler:(UIButton *)sender
{
//创建分享内容
NSString *imagePath = [[NSBundle mainBundle] pathForResource:IMAGE_NAME ofType:IMAGE_EXT];
id<ISSContent> publishContent = [ShareSDK content:CONTENT
defaultContent:@""
image:[ShareSDK imageWithPath:imagePath]
title:@"ShareSDK"
url:@"http://www.mob.com"
description:nil
mediaType:SSPublishContentMediaTypeNews];
id<ISSAuthOptions> authOptions = [ShareSDK authOptionsWithAutoAuth:YES
allowCallback:YES
authViewStyle:SSAuthViewStyleFullScreenPopup
viewDelegate:nil
authManagerViewDelegate:_appDelegate.viewDelegate];
//在授权页面中添加关注官方微博
[authOptions setFollowAccounts:[NSDictionary dictionaryWithObjectsAndKeys:
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeSinaWeibo),
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeTencentWeibo),
nil]];
//显示分享菜单
[ShareSDK showShareViewWithType:ShareTypeWeixiSession
container:nil
content:publishContent
statusBarTips:YES
authOptions:authOptions
shareOptions:[ShareSDK defaultShareOptionsWithTitle:nil
oneKeyShareList:[NSArray defaultOneKeyShareList]
qqButtonHidden:NO
wxSessionButtonHidden:NO
wxTimelineButtonHidden:NO
showKeyboardOnAppear:NO
shareViewDelegate:_appDelegate.viewDelegate
friendsViewDelegate:_appDelegate.viewDelegate
picViewerViewDelegate:nil]
result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
if (state == SSPublishContentStateSuccess)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_SUC", @"发表成功"));
}
else if (state == SSPublishContentStateFail)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_FAI", @"发布失败!error code == %d, error code == %@"), [error errorCode], [error errorDescription]);
}
}];
}
/**
* @brief 分享给微信朋友圈
*
* @param sender 事件对象
*/
- (void)shareToWeixinTimelineClickHandler:(UIButton *)sender
{
//创建分享内容
NSString *imagePath = [[NSBundle mainBundle] pathForResource:IMAGE_NAME ofType:IMAGE_EXT];
id<ISSContent> publishContent = [ShareSDK content:CONTENT
defaultContent:@""
image:[ShareSDK imageWithPath:imagePath]
title:@"ShareSDK"
url:@"http://www.mob.com"
description:nil
mediaType:SSPublishContentMediaTypeNews];
id<ISSAuthOptions> authOptions = [ShareSDK authOptionsWithAutoAuth:YES
allowCallback:YES
authViewStyle:SSAuthViewStyleFullScreenPopup
viewDelegate:nil
authManagerViewDelegate:_appDelegate.viewDelegate];
//在授权页面中添加关注官方微博
[authOptions setFollowAccounts:[NSDictionary dictionaryWithObjectsAndKeys:
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeSinaWeibo),
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeTencentWeibo),
nil]];
//显示分享菜单
[ShareSDK showShareViewWithType:ShareTypeWeixiTimeline
container:nil
content:publishContent
statusBarTips:YES
authOptions:authOptions
shareOptions:[ShareSDK defaultShareOptionsWithTitle:nil
oneKeyShareList:[NSArray defaultOneKeyShareList]
qqButtonHidden:NO
wxSessionButtonHidden:NO
wxTimelineButtonHidden:NO
showKeyboardOnAppear:NO
shareViewDelegate:_appDelegate.viewDelegate
friendsViewDelegate:_appDelegate.viewDelegate
picViewerViewDelegate:nil]
result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
if (state == SSPublishContentStateSuccess)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_SUC", @"发表成功"));
}
else if (state == SSPublishContentStateFail)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_FAI", @"发布失败!error code == %d, error code == %@"), [error errorCode], [error errorDescription]);
}
}];
}
/**
* @brief 简单分享全部
*
* @param sender 事件对象
*/
- (void)simpleShareAllButtonClickHandler:(id)sender
{
NSString *imagePath = [[NSBundle mainBundle] pathForResource:IMAGE_NAME ofType:IMAGE_EXT];
//构造分享内容
id<ISSContent> publishContent = [ShareSDK content:CONTENT
defaultContent:@""
image:[ShareSDK imageWithPath:imagePath]
title:@"ShareSDK"
url:@"http://www.mob.com"
description:NSLocalizedString(@"TEXT_TEST_MSG", @"这是一条测试信息")
mediaType:SSPublishContentMediaTypeNews];
//以下信息为特定平台需要定义分享内容,如果不需要可省略下面的添加方法
//定制人人网信息
[publishContent addRenRenUnitWithName:NSLocalizedString(@"TEXT_HELLO_RENREN", @"Hello 人人网")
description:INHERIT_VALUE
url:INHERIT_VALUE
message:INHERIT_VALUE
image:INHERIT_VALUE
caption:nil];
//定制QQ空间信息
[publishContent addQQSpaceUnitWithTitle:NSLocalizedString(@"TEXT_HELLO_QZONE", @"Hello QQ空间")
url:INHERIT_VALUE
site:nil
fromUrl:nil
comment:INHERIT_VALUE
summary:INHERIT_VALUE
image:INHERIT_VALUE
type:INHERIT_VALUE
playUrl:nil
nswb:nil];
//定制微信好友信息
[publishContent addWeixinSessionUnitWithType:INHERIT_VALUE
content:INHERIT_VALUE
title:NSLocalizedString(@"TEXT_HELLO_WECHAT_SESSION", @"Hello 微信好友!")
url:INHERIT_VALUE
thumbImage:[ShareSDK imageWithUrl:@"http://img1.bdstatic.com/img/image/67037d3d539b6003af38f5c4c4f372ac65c1038b63f.jpg"]
image:INHERIT_VALUE
musicFileUrl:nil
extInfo:nil
fileData:nil
emoticonData:nil];
//定制微信朋友圈信息
[publishContent addWeixinTimelineUnitWithType:[NSNumber numberWithInteger:SSPublishContentMediaTypeMusic]
content:INHERIT_VALUE
title:NSLocalizedString(@"TEXT_HELLO_WECHAT_TIMELINE", @"Hello 微信朋友圈!")
url:@"http://y.qq.com/i/song.html#p=7B22736F6E675F4E616D65223A22E4BDA0E4B88DE698AFE79C9FE6ADA3E79A84E5BFABE4B990222C22736F6E675F5761704C69766555524C223A22687474703A2F2F74736D7573696332342E74632E71712E636F6D2F586B303051563558484A645574315070536F4B7458796931667443755A68646C2F316F5A4465637734356375386355672B474B304964794E6A3770633447524A574C48795333383D2F3634363232332E6D34613F7569643D32333230303738313038266469723D423226663D312663743D3026636869643D222C22736F6E675F5769666955524C223A22687474703A2F2F73747265616D31382E71716D757369632E71712E636F6D2F33303634363232332E6D7033222C226E657454797065223A2277696669222C22736F6E675F416C62756D223A22E5889BE980A0EFBC9AE5B08FE5B7A8E89B8B444E414C495645EFBC81E6BC94E594B1E4BC9AE5889BE7BAAAE5BD95E99FB3222C22736F6E675F4944223A3634363232332C22736F6E675F54797065223A312C22736F6E675F53696E676572223A22E4BA94E69C88E5A4A9222C22736F6E675F576170446F776E4C6F616455524C223A22687474703A2F2F74736D757369633132382E74632E71712E636F6D2F586C464E4D31354C5569396961495674593739786D436534456B5275696879366A702F674B65356E4D6E684178494C73484D6C6A307849634A454B394568572F4E3978464B316368316F37636848323568413D3D2F33303634363232332E6D70333F7569643D32333230303738313038266469723D423226663D302663743D3026636869643D2673747265616D5F706F733D38227D"
thumbImage:[ShareSDK imageWithUrl:@"http://img1.bdstatic.com/img/image/67037d3d539b6003af38f5c4c4f372ac65c1038b63f.jpg"]
image:INHERIT_VALUE
musicFileUrl:@"http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"
extInfo:nil
fileData:nil
emoticonData:nil];
//定制微信收藏信息
[publishContent addWeixinFavUnitWithType:INHERIT_VALUE
content:INHERIT_VALUE
title:NSLocalizedString(@"TEXT_HELLO_WECHAT_FAV", @"Hello 微信收藏!")
url:INHERIT_VALUE
thumbImage:[ShareSDK imageWithUrl:@"http://img1.bdstatic.com/img/image/67037d3d539b6003af38f5c4c4f372ac65c1038b63f.jpg"]
image:INHERIT_VALUE
musicFileUrl:nil
extInfo:nil
fileData:nil
emoticonData:nil];
//定制QQ分享信息
[publishContent addQQUnitWithType:INHERIT_VALUE
content:INHERIT_VALUE
title:@"Hello QQ!"
url:INHERIT_VALUE
image:INHERIT_VALUE];
//定制邮件信息
[publishContent addMailUnitWithSubject:@"Hello Mail"
content:INHERIT_VALUE
isHTML:[NSNumber numberWithBool:YES]
attachments:INHERIT_VALUE
to:nil
cc:nil
bcc:nil];
//定制短信信息
// [publishContent addSMSUnitWithContent:@"Hello SMS"];
[publishContent addSMSUnitWithContent:@"ShareSDK github download address https://github.com/ShareSDKPlatform/ShareSDK-for-iOS"
subject:nil
attachments:@[[ShareSDKCoreService attachmentWithUrl:@"http://f.hiphotos.bdimg.com/album/w%3D2048/sign=df8f1fe50dd79123e0e09374990c5882/cf1b9d16fdfaaf51e6d1ce528d5494eef01f7a28.jpg"]]
to:@[@"15011991178"]];
//定制有道云笔记信息
[publishContent addYouDaoNoteUnitWithContent:INHERIT_VALUE
title:NSLocalizedString(@"TEXT_HELLO_YOUDAO_NOTE", @"Hello 有道云笔记")
author:@"ShareSDK"
source:nil
attachments:INHERIT_VALUE];
//定制Instapaper信息
[publishContent addInstapaperContentWithUrl:INHERIT_VALUE
title:@"Hello Instapaper"
description:INHERIT_VALUE];
//定制搜狐随身看信息
[publishContent addSohuKanUnitWithUrl:INHERIT_VALUE];
//结束定制信息
//创建弹出菜单容器
id<ISSContainer> container = [ShareSDK container];
[container setIPadContainerWithView:sender arrowDirect:UIPopoverArrowDirectionUp];
id<ISSAuthOptions> authOptions = [ShareSDK authOptionsWithAutoAuth:YES
allowCallback:NO
authViewStyle:SSAuthViewStyleFullScreenPopup
viewDelegate:nil
authManagerViewDelegate:_appDelegate.viewDelegate];
//在授权页面中添加关注官方微博
[authOptions setFollowAccounts:[NSDictionary dictionaryWithObjectsAndKeys:
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeSinaWeibo),
[ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
SHARE_TYPE_NUMBER(ShareTypeTencentWeibo),
nil]];
id<ISSShareOptions> shareOptions = [ShareSDK simpleShareOptionsWithTitle:NSLocalizedString(@"TEXT_SHARE_TITLE", @"内容分享")
shareViewDelegate:_appDelegate.viewDelegate];
//弹出分享菜单
[ShareSDK showShareActionSheet:container
shareList:nil
content:publishContent
statusBarTips:YES
authOptions:authOptions
shareOptions:shareOptions
result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
if (state == SSPublishContentStateSuccess)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_SUC", @"分享成功"));
}
else if (state == SSPublishContentStateFail)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_FAI", @"分享失败,错误码:%d,错误描述:%@"), [error errorCode], [error errorDescription]);
}
}];
}