Tommy Peters
Tommy Peters

Reputation: 49

Integrating Facebook to post stuff from iPhone app

I'm trying to implement the functionality of sharing stuff on Facebook in my iPhone app. After walking through https://developers.facebook.com/docs/mobile/ios/build/ It's giving me some trouble!

I use a singleton class to contain the Facebook object. When I click the button to share something, the browser opens and I can login to fb. After that I can press 'okay' and it should redirect me to the app again. Sadly, I get an error message from safari: 'Safari cannot open the page because the address is invalid'

Obviously it's my first time trying to implement fb in an iOS app....

Does anyone have an idea?

Thanks ;-)

Upvotes: 0

Views: 1300

Answers (2)

Malek_Jundi
Malek_Jundi

Reputation: 6160

Check the following in your implementation :

1.you need to add the following functions in your application delegate(the facebook object here is your instance value of FaceBook Class).

// Pre 4.2 support
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{
   return [facebook handleOpenURL:url]; 
}

// For 4.2+ support
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
   return [facebook handleOpenURL:url]; 
}

2.In your info.plist add to URL types > URL Schemes > your Facebook app ID with fb prefix (finally your value will be like this for ex. fb313714***).

Upvotes: 0

Juicy Scripter
Juicy Scripter

Reputation: 25938

You need to register a URL Scheme for your application so it can be opened from browser/other applications (like Facebook's official one).

This is described in Step 3: Implementing Single Sign-On (SSO) part of the tutorial you refer to (especially "Modify the app property list file" section).

Upvotes: 2

Related Questions