How to use Facebook Connect in an iPhone webapp

Viewed 6424

I'm trying to use Facebook Connect from an iPhone webapp, so it would look similar to how it looks in a native iPhone app which is using the Facebook Connect iPhone SDK.

The iPhone SDK gets the nice login page by visiting:

http://www.facebook.com/login.php?fbconnect=1&connect_display=touch&api_key=<key>&next=fbconnect://success

(see http://github.com/facebook/facebook-iphone-sdk/blob/master/src/FBLoginDialog.m)

Since I don't want Safari to open, the only way I see to show this page is by using an iframe.

Then there's the problem of detecting success and failure.

The SDK can do this by simply using the webView:shouldStartLoadWithRequest: delegate method and checking for fbconnect://success and fbconnect://cancel.

As far as I know, the parent page cannot monitor the URL of the iframe.

I could open a Comet connection to a server from the parent page and have Facebook redirect to my server, which would then notify the parent page on success. But I don't like the idea of intruducing a server component to my webapp just because of this.

Does anyone have any clever ideas?

Edit: This is about a web-app, not a native app.

7 Answers

Using Sharekit is a good option until you just wanna move out of the problem. As it provides ready made classes for you. Simply calling methods would be sufficient even for other social networking sites as well like Twitter. Moreover, you can add your custom methods to it as per your need.

Related