官方下载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. [LoadRunner]性能测试实践_Hessian协议脚本编写2

    协议选取和运行配置请参考:http://www.cnblogs.com/whylaughing/p/5430821.html 这次直接贴代码让大家参考: import lrapi.lr; import ...

  2. (ios实战)单个ViewControl适配不同ios版本xib文件实现

    xcode5 中的界面布局 根据sdk 分成ios7.0 and Later 和 ios6.1 and Earlier 两种,那如何xib同时支持 ios6 和ios7 的界面呢 方法如下: 在xco ...

  3. 史上最全的MSSQL复习笔记 (转连接)

    http://www.cnblogs.com/gameworld/p/4790881.html

  4. Linux Shell 06 数学运算

    1.let let "var+=1" let v2= echo $var,$v2 #2,4 a.只支持整数运算 b.基本支持所有运算符(包括++,——,**) c.表达式中使用变量 ...

  5. Linux系统命令查询软件包

    转载自:http://blog.chinaunix.net/uid-346158-id-2131252.html,http://www.jb51.net/os/RedHat/1102.html, 一. ...

  6. nginx看端口使用情况

    [root@iZ94j7ahvuvZ sbin]# netstat -apn Active Internet connections (servers and established) Proto R ...

  7. c# 参数传递

    c#类型有值类型与引用类型. 无论哪种类型的变量,作为方法的参数进行传递时,默认是以"值传递"方式来传递的. 传递给方法的形参,在执行时都会新创建一个局部变量,然后接受实参的值, ...

  8. [转]Oracle分页之三:利用PagerView来实现无刷新GridView

    本文转自:http://www.cnblogs.com/scy251147/archive/2011/04/16/2018355.html 接上面一节,上面还存在问题就是分页控件使用的仍然是服务器端控 ...

  9. hdu 5800 To My Girlfriend + dp

    传送门:hdu 5800 To My Girlfriend 题意:给定n个物品,其中i,j必选,l,m必不选,问组成体积为s的方法一共有多少种 思路:定义dp[i][j][s1][s2],表示前i种物 ...

  10. readonly与const

    readonly与const 在C#中,readonly 与 const 都是定义常量,但不同之处在于:readonly 是运行时常量,而 const 是编译时常量. ; public void Te ...