分享ShareSDK

遇到的问题:当网址包含汉字时,可以分享成功,但只能显示一张大图,不能响应点击事件;

 

 

 

 

 

1\首先获取shareSDK的AppKey,进入后台创建应用,获取AppKey

 

2\cocoapods导入shareSDK

# 主模块(必须)
pod 'ShareSDK3'
# Mob 公共库(必须) 如果同时集成SMSSDK iOS2.0:可看此注意事项:http://bbs.mob.com/thread-20051-1-1.html
pod 'MOBFoundation'
 
# UI模块(非必须,需要用到ShareSDK提供的分享菜单栏和分享编辑页面需要以下1行)
pod 'ShareSDK3/ShareSDKUI'
 
# 平台SDK模块(对照一下平台,需要的加上。如果只需要QQ、微信、新浪微博,只需要以下3行)
pod 'ShareSDK3/ShareSDKPlatforms/QQ'
pod 'ShareSDK3/ShareSDKPlatforms/SinaWeibo'
pod 'ShareSDK3/ShareSDKPlatforms/WeChat'
 
pod 'ShareSDK3/ShareSDKPlatforms/RenRen'
pod 'ShareSDK3/ShareSDKPlatforms/AliPaySocial'
pod 'ShareSDK3/ShareSDKPlatforms/Kakao'
 

三、快速集成

第一步:设置ShareSDK的Appkey并初始化对应的第三方社交平台 打开*AppDelegate.m(*代表你的工程名字)导入头文件

 

在- (BOOL)application: didFinishLaunchingWithOptions:方法中调用registerApp方法来初始化SDK并且初始化第三方平台(各社交平台申请APPkey 的网址及申请流程汇总)

 

第二步:添加实现代码 打开需要集成分享功能的视图

自己布置UI,在button点击事件中执行如下代码

UIImage *image = [UIImage imageNamed:@"60"];

    NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];

    [shareParams SSDKSetupShareParamsByText:@"分享内容"

                                     images:image

                                        url:[NSURL URLWithString:@"http://blog.sina.com.cn/s/blog_6b1e4a060102w9te.html"]

                                      title:@"分享标题"

                                      type:SSDKContentTypeAuto];

 

    [ShareSDK share:SSDKPlatformSubTypeWechatTimeline parameters:shareParams onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {

        

                switch (state) {

                    case SSDKResponseStateSuccess:

                    {

                        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"

                                                                            message:nil

                                                                           delegate:nil

                                                                  cancelButtonTitle:@"确定"

                                                                  otherButtonTitles:nil];

                        [alertView show];

                        break;

                    }

                    case SSDKResponseStateFail:

                    {

                        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"分享失败"

                                                                        message:[NSString stringWithFormat:@"%@",error]

                                                                       delegate:nil

                                                              cancelButtonTitle:@"OK"

                                                              otherButtonTitles:nil, nil];

                        [alert show];

                        break;

                    }

                    default:

                        break;

                        

                }

    }];

    

 

 

 

 

 

 

posted on 2016-06-19 19:36  小艾的博客  阅读(1371)  评论(0编辑  收藏  举报

导航