iOS下 Sharesdk 2.10.4 适配facebook分享

来源:互联网 发布:b2b2c网站源码 编辑:程序博客网 时间:2024/05/17 03:19

还是参考快速集成指南:

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:SSAuthViewStyleFullScreenPopupviewDelegate:nil authManagerViewDelegate:AppDelegateHD.agviewDelegate];[ShareSDK showShareViewWithType:shareType container:[ShareSDK container]content:shareContentstatusBarTips:YES  authOptions:shareAuthOptions shareOptions:[ShareSDK defaultShareOptionsWithTitle:[ShareSDK getClientNameWithType:shareType] oneKeyShareList:nil//[NSArray defaultOneKeyShareList]  qqButtonHidden:YES wxSessionButtonHidden:YESwxTimelineButtonHidden:YES  showKeyboardOnAppear:NO  shareViewDelegate:AppDelegateHD.agviewDelegatefriendsViewDelegate: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中设置


0 0
原创粉丝点击