iOS friends share--integrated with Facebook's official SDK

Source: Internet
Author: User

Friends have been using the alliance to share, recently the customer asked for a new demand can be shared to Facebook think friends of the league have FB share extremely excited ah.

But the test found that friends of the league's two kinds of Facebook have a certain problem.

The first use of the system comes with Facebook to set up a Facebook account on the phone first

Pros: This sharing is simple without the need to configure Facebook AppID

Cons: Inherited the system Facebook can not pre-fill the characteristics of the share content (the general app sharing content is to pre-fill in how to get the king to sell melons is not right.) So this disadvantage is very deadly);

Second: Use in-app Web sharing (this sharing of the League of Friends official demo can not share success = =)

Advantages: No need to think, there is no merit

Cons: They're not going to share, you know?

In that case. Can only be manually integrated ... = =

---------above is purely complaining----

It's not cumbersome to integrate with friends.

First you need to enter https://developers.facebook.com register an app to get an app ID

Official Document Address https://developers.facebook.com/docs/ios/getting-started

First download the Facebook SDK download down is the. Pkg installation file

Installation completed in~/Documents/FacebookSDK 路径下 可以找到 Facebook的sdk

Drag the Fbsdkloginkit.framework fbsdksharekit.framework fbsdkcorekit.framework to the project

Select Create groups for any added folders .

Create a new Facebookappid key in the project's. plist file, which is the AppID that was applied on Facebook after registering the app

then click on the URL types plus sign in the URL schemes to fill in the fb+appid (e.g., fb91136964205)

Finally, add the following code to the APPDELEGATE.M

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  return [[FBSDKApplicationDelegate sharedInstance] application:application                                  didFinishLaunchingWithOptions:launchOptions];}- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {  return [[FBSDKApplicationDelegate sharedInstance] application:application                                                        openURL:url                                              sourceApplication:sourceApplication                                                     annotation:annotation];}

 ---到这里--Facebook SDK 集成完毕-----

Then we need to redefine the Sharetofacebook platform of the Friends League.

Intercept the click events of the Friends League Facebook platform and go to the official SDK

Umsocialsnsplatform *fbplatform = [Umsocialsnsplatformmanager Getsocialplatformwithname:umsharetofacebook];

Fbplatform.needlogin = NO;

NSString *shareurlstr = @ "www.baidu.com";

Fbplatform.snsclickhandler = ^ (Uiviewcontroller *presentingcontroller, Umsocialcontrollerservice * Socialcontrollerservice, BOOL Ispresentincontroller) {

Fbsdksharelinkcontent *content = [[Fbsdksharelinkcontent alloc] init];

Content.contenturl = [Nsurl urlwithstring:shareurlstr];

Content.contentdescription = Sharecontenttext;

Content.contenttitle = @ "Test SHAREFB";

Content.imageurl = [Nsurl urlwithstring:@ "http://dev.umeng.com/system/images/ W1siziisijiwmtqvmdmvmtivmtzfmjffndbfntc3x3nvy2lhbf9zagfyzwxpc3rfywn0aw9uc2hlzxqucg5nil1d/social_sharelist_ Actionsheet.png "];

[Fbsdksharedialog showfromviewcontroller:self

Withcontent:content

Delegate:nil];

};

---here--^_^.

PS: I don't want to say it dry. But not always write blog. Don't know how to add pictures = =

Demo Address: Https://github.com/Rachel829/UMShareToFBDemo

iOS friends share--integrated with Facebook's official SDK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.