1)按需要在Podfile 文件中添加命令:
主模塊(必須)
pod 'mob_sharesdk'
UI模塊(非必須,需要用到ShareSDK提供的分享菜單欄和分享編輯頁面需要以下1行)
pod 'mob_sharesdk/ShareSDKUI'
平臺(tái)SDK模塊(對(duì)照一下平臺(tái),需要的加上。如果只需要QQ、微信、新浪微博,只需要以下3行)
pod 'mob_sharesdk/ShareSDKPlatforms/QQ'
pod 'mob_sharesdk/ShareSDKPlatforms/SinaWeibo'
pod 'mob_sharesdk/ShareSDKPlatforms/WeChat' //(微信sdk不帶支付的命令)
pod 'mob_sharesdk/ShareSDKPlatforms/WeChatFull' //(微信sdk帶支付的命令,和上面不帶支付的不能共存,只能選擇一個(gè))
pod 'mob_sharesdk/ShareSDKPlatforms/SMS'//短信
二.配置集成
1.設(shè)置ShareSDK的appkey

1224_446_285.69.png
提示:如果您同時(shí)多個(gè)MOBSDK產(chǎn)品 在info.plist中的設(shè)置一次就可以了。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self regist];
return YES;
}
+ (void)regist {
[ShareSDK registPlatforms:^(SSDKRegister *platformsRegister) {
[platformsRegister setupSMSOpenCountryList:NO];
//QQ
[platformsRegister setupQQWithAppId:@"" appkey:@""];
//微信
[platformsRegister setupWeChatWithAppId:@"" appSecret:@""];
//新浪
[platformsRegister setupSinaWeiboWithAppkey:@"" appSecret:@"" redirectUrl:@"http://www.sharesdk.cn"];
}];
}
+ (void)share {
NSMutableDictionary *params = [NSMutableDictionary dictionary];
NSURL *url = [NSURL URLWithString:@"http://www.mob.com/"];
[params SSDKSetupShareParamsByText:@"test"
images:[UIImage imageNamed:@"AppIcon.png"]
url:url
title:@"title"
type:SSDKContentTypeAuto];
// 定制新浪微博的分享內(nèi)容
[params SSDKSetupSinaWeiboShareParamsByText: ChangeStr(@"testWB,%@",url)
title:nil
images:[UIImage imageNamed:@"AppIcon.png"]
video:nil
url:nil
latitude:0
longitude:0
objectID:0
isShareToStory:false
type:SSDKContentTypeAuto];
// 定制短信分享內(nèi)容
[params SSDKSetupSMSParamsByText:ChangeStr(@"testSMS,%@",url)title:nil images:nil attachments:nil recipients:nil type:SSDKContentTypeText];
[ShareSDK showShareActionSheet:nil
customItems:nil
shareParams:params
sheetConfiguration:nil
onStateChanged:^(SSDKResponseState state,
SSDKPlatformType platformType,
NSDictionary *userData,
SSDKContentEntity *contentEntity,
NSError *error,
BOOL end)
{
switch (state) {
case SSDKResponseStateSuccess:
NSLog(@"成功");//成功
break;
case SSDKResponseStateFail:
{
NSLog(@"--%@",error.description);
//失敗
break;
}
case SSDKResponseStateCancel:
break;
default:
break;
}
}];
}
白名單配置,各參數(shù)參考mod文檔http://www.mob.com/wiki/detailed?wiki=ShareSDK_ios_whitelist_first&id=14
Info.plist添加 LSApplicationQueriesSchemes 類型Array

WeChat3b3e6687c3afe49f1993d8d6c97262fa.png
各平臺(tái)URL Scheme配置參考:http://www.mob.com/wiki/detailed?wiki=ShareSDK_ios_urlscheme_two&id=14