How to share on Facebook obout iOS?
2015-04-17 14:49
309 查看
本来不是很难的东西,可就是由于英语水平不高,看那些老外的东西有点吃力,希望大家注重英语的积累!
实现facebook分享,主要分为以下几大步骤:
1. 有一个facebook账号,登陆后添加App,获取appID
2. 下载iOS SDK,添加到项目工程
3. 在项目info.plist文件中添加facebookAppID和facebookDisplayName,然后在添加URL Scheme(具体做法见Facebook官网接入文档)
4.
首先将 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 中的
return YES 改为[[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];然后在
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation 方法中添加如下代码
if ([url.hostisEqualToString:@"bridge"])
{
return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:urlsourceApplication:sourceApplicationannotation:annotation];
}
5.接下来是较重要的一步,导入sdk,遵守协议,实现三个相关协议方法(我做的时候,无论分享成功还是取消分享,都会回调分享成功方法,facebook官网的Demo也是这个效果)。如果这一步漏掉,嘿嘿……
6.最后一步,也是最重要的一步,分享代码实现:
FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:contentURLStr]; //分享链接
content.contentTitle = contentTitle; //分享标题
content.imageURL = [NSURL URLWithString:imageURLStr]; //分享图片
shareDialog.shareContent = content;
shareDialog.delegate = self;
[shareDialog show];
facebook分享就是这么简单,仅仅实现了自定义图片、title和链接的分享,如果哪位觉得我做的不好,请指教,我的QQ:595008741,谢谢!
实现facebook分享,主要分为以下几大步骤:
1. 有一个facebook账号,登陆后添加App,获取appID
2. 下载iOS SDK,添加到项目工程
3. 在项目info.plist文件中添加facebookAppID和facebookDisplayName,然后在添加URL Scheme(具体做法见Facebook官网接入文档)
4.
首先将 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 中的
return YES 改为[[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];然后在
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation 方法中添加如下代码
if ([url.hostisEqualToString:@"bridge"])
{
return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:urlsourceApplication:sourceApplicationannotation:annotation];
}
5.接下来是较重要的一步,导入sdk,遵守协议,实现三个相关协议方法(我做的时候,无论分享成功还是取消分享,都会回调分享成功方法,facebook官网的Demo也是这个效果)。如果这一步漏掉,嘿嘿……
6.最后一步,也是最重要的一步,分享代码实现:
FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:contentURLStr]; //分享链接
content.contentTitle = contentTitle; //分享标题
content.imageURL = [NSURL URLWithString:imageURLStr]; //分享图片
shareDialog.shareContent = content;
shareDialog.delegate = self;
[shareDialog show];
facebook分享就是这么简单,仅仅实现了自定义图片、title和链接的分享,如果哪位觉得我做的不好,请指教,我的QQ:595008741,谢谢!
相关文章推荐
- How to use Facebook iOS SDK on iOS 10
- iPhone - How to send image + text on facebook using sharekit
- how to post URL with Image on facebook by ShareKit
- How to create iOS 8 Today extension and share data with containing app – tutorial
- How to Turn on iOS Diagnostics and Send Crash Reports
- Experience share on how to perform trouble shooting – a CRM Central Instance down problem
- How to solve second button click download problem on SharePoint 2010
- how to tag a photo to be used as a thumbnail when page is linked to on facebook
- Core Data on iOS 5 Tutorial: How To Use NSFetchedResultsController
- iOS: How To Make AutoLayout Work On A ScrollView
- How to detect screenshots on iOS (like SnapChat)
- Core Data on iOS 5 Tutorial: How To Preload and Import Existing Data
- How to Parse HTML on iOS
- How to Enable Office Web Apps on SharePoint 2010
- how to update facebook share link, titile, description
- How to install IPA directly on your iOS! [iPhone/iPod/iPad]
- 【转】How to install and configure SharePoint Server 2010 SP1 on the existing SP 2010 Farm
- I'm on Facebook--Now What???: How to Get Personal, Business, and Professional Value from Facebook
- How to Customize UITabBar on iOS 5
- IOS: How to authenticate the GKLocalPlayer on my 'third party server'.