1.首先要先注册自己的appkey在shareSDK官网里面

2.下载shareSDK 文档,可以根据需要下载自己需要的

如图

3.将下载好的shareSDK 解压后加入工程里面

4.添加依赖库

//必须添加的库

必须添加的依赖库如下(Xcode 7 下 .dylib库后缀名更改为.tbd):

libicucore.dylib

libz.dylib

libstdc++.dylib

JavaScriptCore.framework

新浪微博SDK依赖库

ImageIO.framework

libsqlite3.dylib

QQ好友和QQ空间SDK依赖库

libsqlite3.dylib

微信SDK依赖库

libsqlite3.dylib

短信和邮件需要依赖库

MessageUI.framework

5.打开*AppDelegate.m

导入需要的头文件 如图

6.在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions里面添加代码

  • (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions

    {

    /

    • 设置ShareSDK的appKey,如果尚未在ShareSDK官网注册过App,请移步到http://mob.com/login 登录后台进行应用注册

    • 在将生成的AppKey传入到此方法中。

    • 方法中的第二个第三个参数为需要连接社交平台SDK时触发,

    • 在此事件中写入连接代码。第四个参数则为配置本地社交平台时触发,根据返回的平台类型来配置平台信息。

    • 如果您使用的时服务端托管平台信息时,第二、四项参数可以传入nil,第三项参数则根据服务端托管平台来决定要连接的社交SDK。

      */

      [ShareSDK registerApp:@"iosv1101"

      activePlatforms:@[

      @(SSDKPlatformTypeSinaWeibo),

      @(SSDKPlatformTypeMail),

      @(SSDKPlatformTypeSMS),

      @(SSDKPlatformTypeCopy),

      @(SSDKPlatformTypeWechat),

      @(SSDKPlatformTypeQQ),

      @(SSDKPlatformTypeRenren),

      @(SSDKPlatformTypeGooglePlus)]

      onImport:^(SSDKPlatformType platformType)

      {

      switch (platformType)

      {

      case SSDKPlatformTypeWechat:

      [ShareSDKConnector connectWeChat:[WXApi class]];

      break;

      case SSDKPlatformTypeQQ:

      [ShareSDKConnector connectQQ:[QQApiInterface class] tencentOAuthClass:[TencentOAuth class]];

      break;

      case SSDKPlatformTypeSinaWeibo:

      [ShareSDKConnector connectWeibo:[WeiboSDK class]];

      break;

      case SSDKPlatformTypeRenren:

      [ShareSDKConnector connectRenren:[RennClient class]];

      break;

      default:

      break;

      }

      }

      onConfiguration:^(SSDKPlatformType platformType, NSMutableDictionary *appInfo)

      {

        switch (platformType)
      {
      case SSDKPlatformTypeSinaWeibo:
      //设置新浪微博应用信息,其中authType设置为使用SSO+Web形式授权
      [appInfo SSDKSetupSinaWeiboByAppKey:@"568898243"
      appSecret:@"38a4f8204cc784f81f9f0daaf31e02e3"
      redirectUri:@"http://www.sharesdk.cn"
      authType:SSDKAuthTypeBoth];
      break;
      case SSDKPlatformTypeWechat:
      [appInfo SSDKSetupWeChatByAppId:@"wx4868b35061f87885"
      appSecret:@"64020361b8ec4c99936c0e3999a9f249"];
      break;
      case SSDKPlatformTypeQQ:
      [appInfo SSDKSetupQQByAppId:@"100371282"
      appKey:@"aed9b0303e3ed1e27bae87c33761161d"
      authType:SSDKAuthTypeBoth];
      break;
      case SSDKPlatformTypeRenren:
      [appInfo SSDKSetupRenRenByAppId:@"226427"
      appKey:@"fc5b8aed373c4c27a05b712acba0f8c3"
      secretKey:@"f29df781abdd4f49beca5a2194676ca4"
      authType:SSDKAuthTypeBoth];
      break;
      case SSDKPlatformTypeGooglePlus:
      [appInfo SSDKSetupGooglePlusByClientID:@"232554794995.apps.googleusercontent.com"
      clientSecret:@"PEdFgtrMw97aCvf0joQj7EMk"
      redirectUri:@"http://localhost"];
      break;
      default:
      break;
      }

      }];

      return YES;

      }

7.在你点击方法里面加入代码

//1、创建分享参数

NSArray* imageArray = @[[UIImage imageNamed:@"shareImg.png"]];

(注意:图片必须要在Xcode左边目录里面,名称必须要传正确,如果要分享网络图片,可以这样传iamge参数 images:@[@"http://mob.com/Assets/images/logo.png?v=20150320"])

if (imageArray) {

    NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
[shareParams SSDKSetupShareParamsByText:@"分享内容"
images:imageArray
url:[NSURL URLWithString:@"http://mob.com"]
title:@"分享标题"
type:SSDKContentTypeAuto];

//2、分享(可以弹出我们的分享菜单和编辑界面)

[ShareSDK showShareActionSheet:nil //要显示菜单的视图, iPad版中此参数作为弹出菜单的参照视图,只有传这个才可以弹出我们的分享菜单,可以传分享的按钮对象或者自己创建小的view 对象,iPhone可以传nil不会影响

items:nil

shareParams:shareParams

onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {

                   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;
}
}
];}

8.SSO授权登录

注。。。。。。。QQ的SSO授权的 URL Schemes 的 appkey 为16进制;微博分享需要在开发者账号上面申请应用,拿到ID,在微博开放平台上面相应地址填上就可以申请了。

你想要在哪个应用上面分享,你就要去哪个应用的开发平台申请应用,拿到相应的appkey 和 appSecret.

完毕——————。

最新文章

  1. .Net组件程序设计之线程、并发管理(一)
  2. Cocos2d-x lua 游戏中的菜单(Menu)
  3. PHPCMS V9 分页类的修改教程
  4. ie上如何兼容placeholder
  5. Mongodb数据导出工具mongoexport和导入工具mongoimport介绍
  6. 用Java实现约瑟夫环
  7. ubuntu 换源
  8. 自适应的CSS代码片段(常用)
  9. TOMCAT 集群之 PERSISTENT SESSION
  10. 转:Android布局优化
  11. Sublime Text3安装SublimeREPL插件以及快捷键设置
  12. Spring in Action --- 使用MockMvc时报异常
  13. 用雷达统计成绩单、numpy、matplotlib的使用
  14. Flask 中内置的 Session
  15. 第八天py
  16. [leetcode]Jump Game @ Python
  17. linux和window是文件挂载
  18. 五:Jquery-demo
  19. Apollo配置名词-学习1
  20. DRUID控制

热门文章

  1. navigationController 的返回按钮自定义
  2. angular.extend用法实例
  3. 基础的jdbc连接数据库操作
  4. AM335x kernel4.4.12 LCD 时钟翻转设置记录
  5. 【阿里云配置端口开放】使用 iptables
  6. 解决自定义Shiro.Realm扩展类不能用注解(@Resource或@Autowire)自动装配的问题
  7. Yii 1开发日记 -- Ajax实现点击加载下一页
  8. WPF 如何绘制不规则按钮,并且有效点击范围也是不规则的
  9. PHP项目实现手机端和PC端的页面切换
  10. mysql命令行修改字符编码