还是参考快速集成指南:
http://wiki.sharesdk.cn/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E6%8C%87%E5%8D%97/
你需要facebook一个app key, 这个对应的app内的bundle必须包含应用的bundle, 否则分享失败
其次, facebook需要分享回调, 我一开始看文档里面的sharesdk接口 看到wx字样就以为只针对微信的, 后来工作人员和我聊说是全部的整体需要的回调接口
初始化:
[ShareSDK registerApp:@"sharesdk id"];
[ShareSDK connectFacebookWithAppKey:@"app id" appSecret:@"app secret"];
回调函数, 写死就行了:
-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
return [ShareSDK handleOpenURL:url wxDelegate:self];
}
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
return [ShareSDK handleOpenURL:url sourceApplication:sourceApplication annotation:annotation wxDelegate:self];
}
如果没有这个回调函数, 会在授权后无法发送出去分享, 只会在分享窗口和facebook app之间来回切换而已
通用的发送单一分享方法:
id<ISSContent> shareContent= [ShareSDK content:content
defaultContent:@""
image:[ShareSDK jpegImageWithImage:[UIImage imageNamed:SHARE_IMAGE_NAME] quality:0.8]//[ShareSDK imageWithPath:imagePath]
title:[ShareSDK getClientNameWithType:shareType]
url:nil
description:nil
mediaType:SSPublishContentMediaTypeText];
id<ISSAuthOptions> shareAuthOptions=[ShareSDK authOptionsWithAutoAuth:YES
allowCallback:YES
authViewStyle:SSAuthViewStyleFullScreenPopup
viewDelegate:nil
authManagerViewDelegate:AppDelegateHD.agviewDelegate];
[ShareSDK showShareViewWithType:shareType
container:[ShareSDK container]
content:shareContent
statusBarTips:YES
authOptions:shareAuthOptions
shareOptions:[ShareSDK defaultShareOptionsWithTitle:[ShareSDK getClientNameWithType:shareType]
oneKeyShareList:nil//[NSArray defaultOneKeyShareList]
qqButtonHidden:YES
wxSessionButtonHidden:YES
wxTimelineButtonHidden:YES
showKeyboardOnAppear:NO
shareViewDelegate:AppDelegateHD.agviewDelegate
friendsViewDelegate:AppDelegateHD.agviewDelegate
picViewerViewDelegate:nil]
result:^(ShareType type, SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {
if (state == SSResponseStateSuccess)
{
NSLog(@"发表成功");
}
else if (state == SSPublishContentStateFail)
{
NSLog(@"发布失败!error code == %d, error code == %@", [error errorCode], [error errorDescription]);
}
}];
最后需要编辑URL Scheme, 将facebook id加上"fb"前缀就ok, 在info面板最下面的URL Type中设置