// AppDelegate.m // ShareSDK12-25 // // Created by dc004 on 15/12/25. // Copyright © 2015年 gang. All rights reserved. // #import "AppDelegate.h" #import <ShareSDK/ShareSDK.h> #import <TencentOpenAPI/QQApiInterface.h> #import <TencentOpenAPI/TencentOAuth.h> #import "WXApi.h" #import "WeiboSDK.h" #import <RennSDK/RennSDK.h> @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [ShareSDK registerApp:@"dd6883245838"];//字符串爲您的ShareSDK的AppKey //添加新浪微博應用 註冊網址 http://open.weibo.com [ShareSDK connectSinaWeiboWithAppKey:@"568898243" appSecret:@"38a4f8204cc784f81f9f0daaf31e02e3" redirectUri:@"http://www.sharesdk.cn"]; // //當使用新浪微博客戶端分享的時候須要按照下面的方法來初始化新浪的平臺 // [ShareSDK connectSinaWeiboWithAppKey:@"568898243" // appSecret:@"38a4f8204cc784f81f9f0daaf31e02e3" // redirectUri:@"http://www.sharesdk.cn" // weiboSDKCls:[WeiboSDK class]]; // //添加騰訊微博應用 註冊網址 http://dev.t.qq.com // [ShareSDK connectTencentWeiboWithAppKey:@"801307650" // appSecret:@"ae36f4ee3946e1cbb98d6965b0b2ff5c" // redirectUri:@"http://www.sharesdk.cn"]; // // //添加QQ空間應用 註冊網址 http://connect.qq.com/intro/login/ // [ShareSDK connectQZoneWithAppKey:@"100371282" // appSecret:@"aed9b0303e3ed1e27bae87c33761161d" // qqApiInterfaceCls:[QQApiInterface class] // tencentOAuthCls:[TencentOAuth class]]; // // //添加QQ應用 註冊網址 http://mobile.qq.com/api/ // [ShareSDK connectQQWithQZoneAppKey:@"100371282" // qqApiInterfaceCls:[QQApiInterface class] // tencentOAuthCls:[TencentOAuth class]]; // // //微信登錄的時候須要初始化 // [ShareSDK connectWeChatWithAppId:@"wx4868b35061f87885" // appSecret:@"64020361b8ec4c99936c0e3999a9f249" // wechatCls:[WXApi class]]; // //添加人人網應用 註冊網址 http://dev.renren.com [ShareSDK connectRenRenWithAppId:@"226427" appKey:@"fc5b8aed373c4c27a05b712acba0f8c3" appSecret:@"f29df781abdd4f49beca5a2194676ca4" renrenClientClass:[RennClient class]]; //添加開心網應用 註冊網址 http://open.kaixin001.com [ShareSDK connectKaiXinWithAppKey:@"358443394194887cee81ff5890870c7c" appSecret:@"da32179d859c016169f66d90b6db2a23" redirectUri:@"http://www.sharesdk.cn/"]; return YES; } // ViewController.m // ShareSDK12-25 // // Created by dc004 on 15/12/25. // Copyright © 2015年 gang. All rights reserved. // #import "ViewController.h" #import <ShareSDK/ShareSDK.h> @interface ViewController () { UIButton *button; } @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; button = [[UIButton alloc]initWithFrame:CGRectMake(160, 25, 37.5, 30)]; [button setTitle:@"按鈕" forState:UIControlStateNormal]; [button setTitleColor:[UIColor colorWithRed:0 green:1 blue:1 alpha:0.8] forState:UIControlStateNormal]; [button addTarget:self action:@selector(butt:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button]; } -(void)butt:(UIButton *)sender{ NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"ShareSDK" ofType:@"png"]; //構造分享內容 id<ISSContent> publishContent = [ShareSDK content:@"分享內容" defaultContent:@"測試一下" image:[ShareSDK imageWithPath:imagePath] title:@"ShareSDK" url:@"http://www.mob.com" description:@"這是一條測試信息" mediaType:SSPublishContentMediaTypeNews]; //建立彈出菜單容器 id<ISSContainer> container = [ShareSDK container]; [container setIPadContainerWithView:sender arrowDirect:UIPopoverArrowDirectionUp]; //彈出分享菜單 [ShareSDK showShareActionSheet:container shareList:nil content:publishContent statusBarTips:YES authOptions:nil shareOptions:nil result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) { if (state == SSResponseStateSuccess) { NSLog(@"分享成功"); } else if (state == SSResponseStateFail) { NSLog(@"分享失敗,錯誤碼:%ld,錯誤描述:%@", [error errorCode], [error errorDescription]); } }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end