您的位置:首页 > 移动开发 > 微信开发

shareSDK分享 没有安装qq 微信的时候

2015-02-02 15:11 423 查看
在分享时,设备中没有安装应用的时候,提示没有安装。
#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];                                    }                                }                            }];}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐