I've about completed my iOS app but only need to add two buttons:
- Follow us on facebook
- Follow us on twitter
I assumed I would find a couple of simple examples here, but was surprised to find no answer to this at all (yet).
I'm pretty sure I could spend the next few hours trying to figure it out, but thought I'd reach out for a little time-saving help.
Just looking for the code to go behind a button on a view controller (XCode 4.5.1, iOS 6).
I assume the only variable I might need to supply is the company's facebook account name.
Any suggestions? (Thanks in advance!)
First, the URL schem for Facebook:
fb://profile/<yourpageid>
(source). A URL with this structure will open the Facebook app, if it is installed.More on iOS URL schemes.
When your button is tapped, you can check if the Facebook is installed:
For twitter, you follow the same basic steps. The Twitter URL scheme for iOS is
twitter://user?id=12345
ortwitter://user?screen_name=yourname
(source). Again, if the Twitter app is not installed, you have open the twitter profile in safari.As for taking direct actions, I do not think you can do that, since there is no inherent knowledge about any other applciation installed on the device. The best I think you can do is direct users to each respective account.
You could use SLRequest have someone follow you. This will only work on iOS 6 though, on iOS 5 Twitter works but not Facebook.
An example of SLRequest for someone to follow you on Twitter, make sure this is called on the background thread:
And for Facebook you just have to change some of it and look at their API and change the request URL.
this is my code for show people to like the community page of my app.
you can add the _webview where you want to show inside the code.
facebook gives the code for showing the page inside webview.
I am not sure if this is what you are looking for, but I think I found the solution, here at stack overflow on another thread.
Take a look at this thread: Adding the Facebook Like Button in an iPhone App
Hope that helps you!
facebook have a page about adding a button, see on this link,
https://developers.facebook.com/docs/reference/plugins/follow/
and twitters is here
https://support.twitter.com/articles/20164833-how-to-add-the-follow-button-to-your-website
hope it helps