#import <ShareSDK/ShareSDK.h>
#import "WXApi.h"
#import <TencentOpenAPI/QQApi.h>
- (IBAction)docShare:(id)sender {
NSArray *shareList = [ShareSDK getShareListWithType:
ShareTypeWeixiSession,
ShareTypeWeixiTimeline,
ShareTypeQQ,
nil];
//定义容器
id<ISSContainer> container = [ShareSDK container];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
[container setIPadContainerWithView:sender
arrowDirect:UIPopoverArrowDirectionUp];
}
else
{
[container setIPhoneContainerWithViewController:self];
}
//定义分享内容
id<ISSContent> publishContent = nil;
NSString *contentString =contentShare;
NSString *titleString = titleShare;
NSString *urlString = urlShare;
NSString *description = summaryShare;
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"Icon@2x" ofType:@"png"];
publishContent = [ShareSDK content:contentString
defaultContent:@""
image:[ShareSDK imageWithPath:imagePath]
title:titleString
url:urlString
description:description
mediaType:SSPublishContentMediaTypeNews];
//定义分享设置
id<ISSShareOptions> shareOptions = [ShareSDK simpleShareOptionsWithTitle:@"分享内容" shareViewDelegate:nil];
[ShareSDK showShareActionSheet:container
shareList:shareList
content:publishContent
statusBarTips:NO
authOptions:nil
shareOptions:shareOptions
result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {//返回事件
if (state == SSPublishContentStateSuccess)
{
NSLog(NSLocalizedString(@"TEXT_SHARE_SUC", @"分享成功!"));
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
message:@"分享成功"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil,nil];
[alert show];
}
else if (state == SSPublishContentStateFail)
{
if (type==24&&![QQApi isQQInstalled]) {
//分享到QQ
//没有安装qq
NSLog(NSLocalizedString(@"TEXT_SHARE_FAI", @"没有安装QQ!"), [error errorCode], [error errorDescription]);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
message:@"没有安装QQ"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil,nil];
[alert show];
}else if ((type==22||type==23)&&![WXApi isWXAppInstalled]) {
//没有安装qq || 没有安装微信
NSLog(NSLocalizedString(@"TEXT_SHARE_FAI", @"没有安装微信!"), [error errorCode], [error errorDescription]);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
message:@"没有安装微信"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil,nil];
[alert show];
}else {
NSLog(NSLocalizedString(@"TEXT_SHARE_FAI", @"分享失败!"), [error errorCode], [error errorDescription]);
NSLog(NSLocalizedString(@"TEXT_SHARE_SUC", @"分享成功!"));
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
message:@"分享失败"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil,nil];
[alert show];
}
}
}];
}
shareSDK分享 没有安装qq 微信的时候
最新推荐文章于 2018-07-28 10:47:32 发布
在分享时,设备中没有安装应用的时候,提示没有安装。