Opening your Facebook Page from an iOS App in the Facebook App

A major part of marketing for apps today is social media and one of the biggest is Facebook and managing to get people to “like” your apps Facebook page. Facebook doesn’t allow apps to have their own “like” button in their app, this is to stop people writing apps that automatically “like” pages, makes sense! So you are left with taking the user to your page and hoping they click the like button.

On iPhone/iPad iOS the Facebook app opens when you open an URL that starts with “fb://”. Add “profile/” and then your Facebook page ID number and you can open your fan-page. To get your ID the simplest way is to goto your pages news feed, make sure you are logged in as the administrator, click the “Edit” drop down menu and click “Update Info”. Now in the URL bar you will see your pages ID number as part of the URL, see the screen-shot below:


To open the URL and actually open the Facebook app to the page use the Obj-C code like below. Note the “OpenURL” function first checks to see if the URL can be opened and fails if it can’t. It will fail with our new Facebook URL if the Facebook app isn’t installed, in this case we just open our normal URL and this will open in the web browser instead.

[codebox 1]

Op calling the OpenURL ObjC code from Cocos2d-x:

[codebox 2]

Get my ObjC sample code file here: Calling ObjC from Cocos2D-X iOS