官方下载ShareSDK iOS:http://sharesdk.cn/

ShareSDK社会化分享

包含“社会化分享组件”“社会化登录组件”“第三方评论和赞”三大模块,并有详尽的数据统计后台,助力移动开发者接入第三方平台实现快速成长。

ShareSDK产品介绍

ShareSDK是为iOS、Android的App提供社会化功能的一个组件,开发者仅需10分钟即可集成到自己的 App中,它不仅支持国内外40多家的主流社交平台,帮助开发者轻松实现社会化分享、登录、关注、获得用户资料、获取好友列表等主流的社会化功能,还有强 大的社会化统计分析管理后台,可以实时了解用户、信息流、回流率、传播效率等数据,有效地指导移动App的日常运营与推广,同时为App引入更多的社会化 流量。

为什么使用ShareSDK?

快速获取更多用户

更流畅的体验 ShareSDK统一了所有的社交平台的接口,并拥有完善的开发文档;

更高效的推广

ShareSDK七大优势

永久免费

自定义UI

一键分享

支持平台最全

SDK体积最小

数据统计最全

深度支持游戏:

  • 好友关系运用——邀请好友、求助、发起挑战、索取道具、好友排行、分享炫耀。

ShareSDK功能介绍

1 一键分享

支持分享文字、图片、图文、音乐、视频、链接,可一键分享至微信、微博、Facebook、Twitter等多个平台;支持@好友和话题功能。轻松实现你分享出去的链接中,仅让用户看到您的官网地址,而并非ShareSDK。

2 第三方登录

利用第三方社交网络账号QQ、微博等方式登录APP更方便快捷,用户授权后,开发者也可方便获取用户基本信息,如头像、昵称和签名。可轻松实现获取微博好友关系、微博内容、用户资料、LBS信息。

3 评论和赞

用户可通过第三方账号或者自有账号登录,对你设置的主题进行评论或赞,同时您也能在后台审核评论内容,轻松建立社区氛围。

4 给你一个看得见用户分享行为的水晶球——社会化数据统计

ShareSDK统计后台实时查看App各项社会化数据,帮助开发者了解社会化数据的各项指标,便于开发者从社交属性、用户分布、平台选择、营销效果等多个维度评估App,助力产品优化改进。

Share SDK的集成:

前提:在友盟官网注册应用得到appkey (获取AppKey)

如何在我们的官网注册应用得到appkey,请点击链接看里面的操作步骤

(1)官方下载ShareSDK iOS,地址:http://sharesdk.cn/

(2)根据实际情况,引入相关的库,参考官方集成文档。

(3)在项目的AppDelegate中一般情况下有三个操作,第一是注册ShareSDK,第二是注册各个平台的账号,第三是关于微信等应用的回调处理。

在appdelegate.m中:

// 分享
    [DMShare registerApp];
    [DMShare addSharePlat];

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    return [ShareSDK handleOpenURL:url wxDelegate:self];
}

定义一个类继承nsobject:

#import <Foundation/Foundation.h>
#import <ShareSDK/ShareSDK.h>
#import <TencentOpenAPI/QQApiInterface.h>
#import <TencentOpenAPI/TencentOAuth.h>
#import "WXApi.h"
#import "WeiboSDK.h"
#import "DMShareModel.h"

@interface DMShare : NSObject

+ (void)registerApp;
+ (void)addSharePlat;
+ (void)showShare:(DMShareModel *)shareModel addTarget:(id)target;

#import "DMShare.h"

@interface DMShare () <ISSShareViewDelegate>

@end

@implementation DMShare

+ (void)registerApp
{
    [ShareSDK registerApp:@"a63d9d1a2908"];
}

+ (void)addSharePlat
{
    //添加新浪微博应用
//    [ShareSDK connectSinaWeiboWithAppKey:@"199632105"
//                               appSecret:@"526a34cbb19d70f685a1dc25d2e09c76"
//                             redirectUri:@"https://api.weibo.com/oauth2/default.html"];
    
    //添加QQ空间应用
//    [ShareSDK connectQZoneWithAppKey:@"1104479433"
//                           appSecret:@"safjx8rydezdBCZC"
//                   qqApiInterfaceCls:[QQApiInterface class]
//                     tencentOAuthCls:[TencentOAuth class]];
    
    //添加QQ应用
//    [ShareSDK connectQQWithQZoneAppKey:@"1104479433"
//                     qqApiInterfaceCls:[QQApiInterface class]
//                       tencentOAuthCls:[TencentOAuth class]];
    
    //添加微信应用
    [ShareSDK connectWeChatWithAppId:@"wx90b632077a12a1be"
                           appSecret:@"2ba12ff131ca59db383c49cf2ec59e1e"
                           wechatCls:[WXApi class]];
}

+ (void)showShare:(DMShareModel *)shareModel addTarget:(id)target
{
    NSArray *shareList = [ShareSDK getShareListWithType:ShareTypeWeixiSession, ShareTypeWeixiTimeline,nil];
    id<ISSAuthOptions> authOptions = [ShareSDK authOptionsWithAutoAuth:YES
                                                         allowCallback:NO
                                                         authViewStyle:SSAuthViewStyleFullScreenPopup
                                                          viewDelegate:target
                                               authManagerViewDelegate:target];
    //隐藏logo
    [authOptions setPowerByHidden:YES];
    
//    id<ISSShareOptions> shareOptions = [ShareSDK defaultShareOptionsWithTitle:@"内容分享"
//                                                              oneKeyShareList:[NSArray defaultOneKeyShareList]
//                                                               qqButtonHidden:YES
//                                                        wxSessionButtonHidden:YES
//                                                       wxTimelineButtonHidden:YES
//                                                         showKeyboardOnAppear:NO
//                                                            shareViewDelegate:target
//                                                          friendsViewDelegate:target
//                                                        picViewerViewDelegate:nil];
    id<ISSShareOptions> shareOptions = [ShareSDK defaultShareOptionsWithTitle:@"内容分享"
                                                              oneKeyShareList:shareList
                                                               qqButtonHidden:YES
                                                        wxSessionButtonHidden:YES
                                                       wxTimelineButtonHidden:YES
                                                         showKeyboardOnAppear:NO
                                                            shareViewDelegate:target
                                                          friendsViewDelegate:target
                                                        picViewerViewDelegate:nil];
    
    //在授权页面中添加关注官方微博
//    [authOptions setFollowAccounts:[NSDictionary dictionaryWithObjectsAndKeys:
//                                    [ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
//                                    SHARE_TYPE_NUMBER(ShareTypeSinaWeibo),
//                                    [ShareSDK userFieldWithType:SSUserFieldTypeName value:@"ShareSDK"],
//                                    SHARE_TYPE_NUMBER(ShareTypeTencentWeibo),
//                                    nil]];
    
    //构造分享内容
    id<ISSContent> publishContent = [ShareSDK content:shareModel.content
                                       defaultContent:shareModel.defaultContent
                                                image:[ShareSDK imageWithPath:shareModel.imageUrl]
                                                title:shareModel.title
                                                  url:shareModel.url
                                          description:shareModel.content
                                            mediaType:SSPublishContentMediaTypeNews];
    //定制QQ空间信息
//    [publishContent addQQSpaceUnitWithTitle:shareModel.title
//                                        url:shareModel.url
//                                       site:nil
//                                    fromUrl:nil
//                                    comment:[SSInheritValue inherit]
//                                    summary:[SSInheritValue inherit]
//                                      image:[SSInheritValue inherit]
//                                       type:[SSInheritValue inherit]
//                                    playUrl:nil
//                                       nswb:nil];
    
    //定制QQ分享信息
//    [publishContent addQQUnitWithType: INHERIT_VALUE
//                              content: shareModel.content
//                                title: shareModel.title
//                                  url: shareModel.url
//                                image:[ShareSDK imageWithPath:shareModel.imageUrl]];
    
    //定制微信好友信息
    [publishContent addWeixinSessionUnitWithType: INHERIT_VALUE
                                         content: INHERIT_VALUE
                                           title: shareModel.title
                                             url: shareModel.url
                                      thumbImage: [ShareSDK imageWithPath:shareModel.imageUrl]
                                           image: INHERIT_VALUE
                                    musicFileUrl: nil
                                         extInfo: nil
                                        fileData: nil
                                    emoticonData: nil];
    
    //定制微信朋友圈信息
    [publishContent addWeixinTimelineUnitWithType: [NSNumber numberWithInteger:SSPublishContentMediaTypeNews]
                                          content: INHERIT_VALUE
                                            title: shareModel.title
                                              url: shareModel.url
                                       thumbImage: [ShareSDK imageWithPath:shareModel.imageUrl]
                                            image: INHERIT_VALUE
                                     musicFileUrl: nil
                                          extInfo: nil
                                         fileData: nil
                                     emoticonData: nil];

//定制微信收藏信息
//    [publishContent addWeixinFavUnitWithType: INHERIT_VALUE
//                                     content: INHERIT_VALUE
//                                       title: shareModel.title
//                                         url: shareModel.url
//                                  thumbImage: [ShareSDK imageWithPath:shareModel.imageUrl]
//                                       image: INHERIT_VALUE
//                                musicFileUrl: nil
//                                     extInfo: nil
//                                    fileData: nil
//                                emoticonData: nil];
    
    
    [ShareSDK showShareActionSheet: nil
                         shareList: shareList
                           content: publishContent
                     statusBarTips: YES
                       authOptions: authOptions
                      shareOptions: shareOptions
                            result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
                                if (state == SSResponseStateSuccess) {
                                    NSLog(@"分享成功");
                                } else if (state == SSResponseStateFail) {
                                    NSLog(@"分享失败,错误码:%d,错误描述:%@", [error errorCode], [error errorDescription]);
                                }
                            }];
    
    [ShareSDK cancelAuthWithType:ShareTypeSinaWeibo];
}

#####分享按钮的触摸事件

#pragma mark - 分享请求
- (void)shareRequestWithParameters:(NSDictionary *)parameters WithButton:(UIButton*)sender
{
    [DMHttpRequest get:DMShareUrl parameters:parameters success:^(id responseObj) {
        DMRequestCode code = [DMTools responseCode:responseObj];
        sender.userInteractionEnabled = YES;
        NSLog(@"%@",responseObj);
        switch (code) {
            case DMRequestSuccess: {
                [self.hud hide:YES];
                //                [DMTools loadSuccessHUD:self.hud text:[DMTools responseMessage:responseObj] delay:DMHUDDelayTimeInterval];
                dispatch_async(dispatch_get_main_queue(), ^{
                    if (responseObj[@"data"]==nil||[responseObj[@"data"]isKindOfClass:[NSNull class]]) {
                        return ;
                    }
                    // 请求完成后加载数据
                    DMShareModel *model = [[DMShareModel alloc]init];
                    model.title = responseObj[@"data"][@"title"];
                    model.content = responseObj[@"data"][@"content"];
                    if ([responseObj[@"data"][@"pic_url"] hasPrefix:@"http"]) {
                        model.imageUrl =  [ShareSDK imageWithUrl:responseObj[@"data"][@"pic_url"]];
                    }else
                    {
                        model.imageUrl = [ShareSDK imageWithPath:[[NSBundle mainBundle] pathForResource:@"icon_钱富宝logo_登录页@3x" ofType:@"png"]] ;
                    }
                    model.url = responseObj[@"data"][@"url"];
                    self.shareModel = model;
                    [[DMShareView shareInstance]showShare:self.shareModel addTarget:self];
                    //                    [DMShare showShare:self.shareModel addTarget:self];
                    
                });
                break;
            }
            default:
                //                [DMTools loadFailedHUD:self.hud text:[DMTools responseMessage:responseObj] delay:DMHUDDelayTimeInterval];
            {
                [self.hud hide:YES];
                [[DMShareView shareInstance]showShare:nil addTarget:self];
                
                break;
            }
        }
        
    } failure:^(NSError *error) {
        [self.hud hide:YES];
        //        [DMTools loadFailedHUD:self.hud text:DMRequestFailureNote delay:DMHUDDelayTimeInterval];
        [[DMShareView shareInstance]showShare:nil addTarget:self];
        sender.userInteractionEnabled = YES;
    }];
}

IOS开发之—— ShareSDK的使用的更多相关文章

  1. iOS开发---集成ShareSDK实现第三方登录、分享、关注等功能。

    (1)官方下载ShareSDK IOS 2.9.6,地址:http://sharesdk.mob.com/Download (2)根据实际情况,引入相关的库,参考官方文档. (3)在项目的AppDel ...

  2. iOS开发系列--通讯录、蓝牙、内购、GameCenter、iCloud、Passbook系统服务开发汇总

    --系统应用与系统服务 iOS开发过程中有时候难免会使用iOS内置的一些应用软件和服务,例如QQ通讯录.微信电话本会使用iOS的通讯录,一些第三方软件会在应用内发送短信等.今天将和大家一起学习如何使用 ...

  3. iOS开发路线简述

    1 iOS开发环境1.1 开发环境标准的配置是MacOSX+Xcode.MacOSX的话首选用苹果电脑,Macmini最便宜只要4000多就好了然后自己配一个显示器,MacBookPro 也可以,不推 ...

  4. iOS开发系列通讯录、蓝牙、内购、GameCenter、iCloud、Passbook系统服务开

    --系统应用与系统服务 iOS开发过程中有时候难免会使用iOS内置的一些应用软件和服务,例如QQ通讯录.微信电话本会使用iOS的通讯录,一些第三方软件会在应用内发送短信等.今天将和大家一起学习如何使用 ...

  5. 李洪强iOS开发支付集成之微信支付

    iOS开发支付集成之微信支付 微信支付也是需要签名的,也跟支付宝一样,可以在客户端签名,也可以在后台签名(当然,为了安全还是推荐在服务器上做签名,逻辑也比较好理解). 1 - 集成前首先要看看文档 开 ...

  6. 【转】iOS开发路线简述

    简单看了下楼主说的很详细,尤其是最后面那个图描述很直观,让想学习ISO开发的程序猿很清晰每个步骤学习的内容,在此收藏下. iOS系统以及iPhone的出来都要感谢乔布斯,一个完美主义者,从如此优秀的i ...

  7. iOS开发支付集成之微信支付

    这一篇是<iOS开发之支付>这一部分的继支付宝支付集成,银联支付集成第三篇,微信支付.在集成的时候建议都要去下载最新版的SDK,因为我知道的前不久支付宝,银联都更新了一次,微信的不太清楚更 ...

  8. iOS开发系列——内购、GameCenter、iCloud、Passbook系统服务开发汇总

    社交 Social 现在很多应用都内置“社交分享”功能,可以将看到的新闻.博客.广告等内容分享到微博.微信.QQ.空间等,其实从iOS6.0开始苹果官方就内置了Social.framework专门来实 ...

  9. iOS开发学习 阶段过程简述

    下面就简单介绍一下我iOS开发的感受,也是学习iOS开发的一个体系架构. 1 iOS开发环境 1.1 开发环境 标准的配置是Mac OS X + Xcode. MacOSX的话首选用苹果电脑,macm ...

随机推荐

  1. win7 64位安装oracle10g出现未知错误,程序异常终止解决方法

    修改Oracle 10G\database\stage\prereq\db\refhost.xml 在 </SYSTEM> <CERTIFIED_SYSTEMS>后面添加 &l ...

  2. "ORA-12154: TNS:could not resolve the connect identifier specified"的解决办法

    添加环境变量解决: 变量名:TNS_ADMIN 变量值:D:\Ocl\product\11.2.0\dbhome_1\NETWORK\ADMIN tnsnames.ora所在的路径

  3. C/S架构程序多种类服务器之间实现单点登录(转)

    (一) 在项目开发的过程中,经常会出现这样的情况:我们的产品包括很多,以QQ举例,如登陆.好友下载.群下载.网络硬盘.QQ游戏.QQ音乐等,总不能要求用户每次输入用户名.密码吧,为解决这个问题,高手提 ...

  4. python模块调用

    1.某个模块1被调用到另一个模块2的时候,当不想模块1中的某些代码在模块2中执行时,可以在模块一种添加如下代码: if    __name__  ==     "__main__" ...

  5. 从SqlServer现有数据生成Insert脚本

    步骤1,打开"Generate and Publish Objects"向导.右键点击要导出数据的数据库,选择Taks->GenerateScript 步骤2,选择要导出数据 ...

  6. ubuntu自带的gedit编辑器添加Markdown预览插件

    gedit安装Markdown Preview Ubuntu自带的gedit编辑器也是有很强大的功能的,且支持插件的安装.对于喜欢用Markdown的我来说,这当然是很好的了,gedit本身 就支持M ...

  7. Hive history date mapping

    Hive history table mapping create table fdl_family as select * from (select 'acc1' as account,'famil ...

  8. Java zip and unzip demo

    目录结构如下: import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import ...

  9. 【NOIP提高组2015D2T1】uva 714 copying books【二分答案】——yhx

    Before the invention of book-printing, it was very hard to make a copy of a book. All the contents h ...

  10. codeforces 477B B. Dreamoon and Sets(构造)

    题目链接: B. Dreamoon and Sets time limit per test 1 second memory limit per test 256 megabytes input st ...