Giter VIP home page Giter VIP logo

sharesdk-ios's Introduction

ShareSDK-iOS

这是一个 ShareSDK 社会化分享 SDK 的非官方镜像。

官方集成指南请参照 http://wiki.mob.com/ios简洁版快速集成/

或者使用官方的 repo : https://github.com/MobClub/ShareSDK3.x-for-iOS

使用CocoaPods安装

CocoaPods 是开发 OS X 和 iOS 应用程序的一个第三方库的依赖管理工具。

要使用 ShareSDK 社会化分享,推荐这样配置 Podfile:

# The front repo is prior if conflicted
# CocoaPods private repo
source 'https://github.com/jcccn/PodSpecs.git'
# CocoaPods master repo
source 'https://github.com/CocoaPods/Specs.git'

platform :ios,'7.0'

# ignore all warnings from all pods
inhibit_all_warnings!

pod 'ShareSDK/Core'
pod 'ShareSDK/ShareSDKUI'
pod 'ShareSDK/ShareSDKPlatforms/QQ'
pod 'ShareSDK/ShareSDKPlatforms/SinaWeibo'
pod 'ShareSDK/ShareSDKPlatforms/WeChat'

也可以这样配置Podfile:

# CocoaPods master repo
source 'https://github.com/CocoaPods/Specs.git'

platform :ios,'7.0'

# ignore all warnings from all pods
inhibit_all_warnings!

pod 'ShareSDK', :git => 'https://github.com/jcccn/ShareSDK-iOS.git'

使用

初始化

在AppDelegate.m文件的 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法中添加如下代码完成SDK的初始化:

-   (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions 
{     
     [ShareSDK registerApp:@"*****"  // *** is the AppKey that you just got 
           activePlatforms:@[
                            @(SSDKPlatformTypeSinaWeibo),
                            @(SSDKPlatformTypeMail),
                            @(SSDKPlatformTypeSMS),
                            @(SSDKPlatformTypeCopy),
                            @(SSDKPlatformTypeWechat),
                            @(SSDKPlatformTypeQQ),
                            @(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;
                  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 SSDKPlatformTypeGooglePlus:
                      [appInfo SSDKSetupGooglePlusByClientID:@"232554794995.apps.googleusercontent.com"
                                                clientSecret:@"PEdFgtrMw97aCvf0joQj7EMk"
                                                 redirectUri:@"http://localhost"];
                    break;
                   default:
                    break;
              }
          }];
 return YES;
}

分享

在需要分享的地方,完成如下代码:

    //1、Create Share parameters
    NSArray* imageArray = @[[UIImage imageNamed:@"shareImg.png"]];
    if (imageArray) {
 
        NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
        [shareParams SSDKSetupShareParamsByText:@"Share Content"
                                         images:imageArray
                                            url:[NSURL URLWithString:@"http://mob.com"]
                                          title:@"ShareTitle"
                                           type:SSDKContentTypeAuto];
        //2、To show the share content view
        [ShareSDK showShareActionSheet:nil //The way to share content for iPad : we recommend you to use a child view of ViewController as the "anchor" to be the container. It can be an button、custom view etc. Only in this way do the share view and authorization view display correctly. 
                                 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:@"Share Success!"
                                                                                   message:nil
                                                                                  delegate:nil
                                                                         cancelButtonTitle:@"OK"
                                                                         otherButtonTitles:nil];
                               [alertView show];
                               break;
                           }
                           case SSDKResponseStateFail:
                           {
                               UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Share Fail"
                                                                                   message:[NSString stringWithFormat:@"%@",error]
                                                                                  delegate:nil
                                                                         cancelButtonTitle:@"OK"
                                                                         otherButtonTitles:nil, nil];
                                [alert show];
                                break;
                               }
                            default:
                               break;
                       }
 
                   }];

详细的社会化分享功能使用,请参考官方文档

sharesdk-ios's People

Contributors

jcccn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sharesdk-ios's Issues

能不能加我的QQ谈下

你好,我是ShareSDK iOS端的负责人,现在我们官方也要支持cocoapods了。目前困扰我们的一个问题就是 pod名 ShareSDK 被占用了,能不能加我的QQ谈下:642270023

TencentOpenAPI和SSZipArchive冲突

duplicate symbol OBJC_IVAR$_SSZipArchive._path in:
/Users/yyy/Library/Developer/Xcode/DerivedData/xxx/Build/Products/Debug-iphonesimulator/libPods.a(SSZipArchive.o)
/Users/yyy/git/xxx/xxx/ShareSDK/Extend/QQConnectSDK/TencentOpenAPI.framework/TencentOpenAPI(TCOSDKSSZipArchive.o)
duplicate symbol OBJC_IVAR$_SSZipArchive._zip in:
/Users/yyy/Library/Developer/Xcode/DerivedData/xxx/Build/Products/Debug-iphonesimulator/libPods.a(SSZipArchive.o)
/Users/yyy/git/xxx/xxx/ShareSDK/Extend/QQConnectSDK/TencentOpenAPI.framework/TencentOpenAPI(TCOSDKSSZipArchive.o)
duplicate symbol OBJC_IVAR$_SSZipArchive._filename in:
/Users/yyy/Library/Developer/Xcode/DerivedData/xxx/Build/Products/Debug-iphonesimulator/libPods.a(SSZipArchive.o)
/Users/yyy/git/xxx/xxx/ShareSDK/Extend/QQConnectSDK/TencentOpenAPI.framework/TencentOpenAPI(TCOSDKSSZipArchive.o)
duplicate symbol OBJC_CLASS$_SSZipArchive in:
/Users/yyy/Library/Developer/Xcode/DerivedData/xxx/Build/Products/Debug-iphonesimulator/libPods.a(SSZipArchive.o)
/Users/yyy/git/xxx/xxx/ShareSDK/Extend/QQConnectSDK/TencentOpenAPI.framework/TencentOpenAPI(TCOSDKSSZipArchive.o)
duplicate symbol OBJC_METACLASS$_SSZipArchive in:
/Users/yyy/Library/Developer/Xcode/DerivedData/xxx/Build/Products/Debug-iphonesimulator/libPods.a(SSZipArchive.o)
/Users/yyy/git/xxx/xxx/ShareSDK/Extend/QQConnectSDK/TencentOpenAPI.framework/TencentOpenAPI(TCOSDKSSZipArchive.o)
ld: 5 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.