I'm building an iOS app with the Facebook SDK.
One of the things my customer wants is a button that launches the Facebook app and shows their Facebook page. Is there some way to do this, perhaps using a URL?
Thanks.
iPhone has a bunch of URL schemes such as:
NSURL *url = [NSURL URLWithString:#"fb://<insert function here>"];
[[UIApplication sharedApplication] openURL:url];
Check this site out for more:
http://wiki.akosma.com/IPhone_URL_Schemes#Facebook
Also check out this SO post for more info:
https://stackoverflow.com/a/10416399/738262
Related
I've tried to use the code below but it keeps taking the user to show the website and I need it to take them to a application on the iPhone, ipad and ipod!
- (IBAction)fbIconGo:(id)sender {
NSURL *fbURL = [[NSURL alloc] initWithString:#"https:facebook.com/numberHERE"];
// check if app is installed
if ( ! [[UIApplication sharedApplication] canOpenURL:fbURL] ) {
// if we get here, we can't open the FB app.
fbURL = [[NSURL alloc] initWithString:#"https:facebook.com/NUMBER HERE"];; // direct URL on FB website to open in safari
}
[[UIApplication sharedApplication] openURL:fbURL];
You can do with:
NSURL *url = [NSURL URLWithString:#"fb://profile/<id>"];
[[UIApplication sharedApplication] openURL:url];
Schemes
fb://profile – Open Facebook app to the user’s profile
fb://friends – Open Facebook app to the friends list
fb://notifications – Open Facebook app to the notifications list (NOTE: there appears to be a bug with this URL. The Notifications page opens. However, it’s not possible to navigate to anywhere else in the Facebook app)
fb://feed – Open Facebook app to the News Feed
fb://events – Open Facebook app to the Events page
fb://requests – Open Facebook app to the Requests list
fb://notes – Open Facebook app to the Notes page
fb://albums – Open Facebook app to Photo Albums list
Your URLs should be changed to use the URL schemes instead , Look at these posts for the complete details,
http://wiki.akosma.com/IPhone_URL_Schemes#Facebook
Open a facebook link by native Facebook app on iOS
If you are trying to navigate to a page or a profile , the address should be as follows,
NSURL *url = [NSURL URLWithString:#"fb://profile/<id>"];
[[UIApplication sharedApplication] openURL:url];
You can use Apple URL schemes to communicate with other apps. Read DOCS Communicating With Other Apps
TO open facebook app use fb: URL scheme; i.e.
NSURL *url = [NSURL URLWithString:#"fb://https:facebook.com/NUMBER HERE"];
[[UIApplication sharedApplication] openURL:url];
I am having an app in which I am opening my Facebook Like page.
I am using this Link for that.
But when I try to open this It doesn't go to my Facebook Like page.
It opens up my app with Logo but there is no like page for my app.
It says " This app is not available for your phone."
I have passed the correct AppId from Facebook.
Do I need to set up any additional details from Facebook Developers Guide?
Please help me. Any help will be appreciated.
For my application, I am using this code and it works pretty well. Seems like you are doing something wrong.
NSURL *url = [NSURL URLWithString:#"fb://profile/268179536658143"];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
EDIT: You were taking App ID, not the fan page ID. Please correct it.
I'm working on something cool and I want to link to my Google+ profile in the iOS app.
Has anyone found out how to use the mgc:// URI scheme that the Google+ app on iOS provides to open a specific profile the way you can do it with fb://, twitter:// and almost every other account-based iOS app?
In fact it's really simple. Check your URL in a web browser and replace http:// or https:// with gplus://
Example :
If the URL in your browser is https://plus.google.com/u/0/100711776131865357077 then you open the profile in the app with the following code.
NSURL *gPlusUrl = [NSURL URLWithString:#"gplus://plus.google.com/u/0/100711776131865357077"];
if ([[UIApplication sharedApplication] canOpenURL:gPlusUrl]) {
[[UIApplication sharedApplication] openURL:gPlusUrl];
}
I know this is an old post, but I found the solution here (just search "google"). The URL scheme is gplus://. I have tested this myself and verified that it worked. Usage example:
NSURL *gPlusUrl = [NSURL URLWithString:#"gplus://"];
if ([[UIApplication sharedApplication] canOpenURL:gPlusUrl]) {
[[UIApplication sharedApplication] openURL:gPlusUrl];
}
I'm trying to link to a specific profile page in the Facebook iOS app by using the (semi-official) URL scheme.
fb://profile/123456789 works fine, but fb://profile/someusername does not. Am I missing something?
This URL works for me: fb://profile?id=<id> where <id> is either the numeric ID or the username.
Not sure whether facebook intends to keep this sort of thing constant, but here is the code that I use in my project. The FB link works on my iPhone (iOS 5) with one of the newer versions of the FB app.
Note that you need the numeric page ID to get the FB app link. This method worked for me: http://inlinevision.com/apps/how-to-find-your-facebook-page-id/
NSURL* direct = [NSURL URLWithString:#"fb://page/NUMERIC_PAGE_ID"];
NSURL* web = [NSURL URLWithString:#"REGULAR_OLD_WEB_LINK"];
if([[UIApplication sharedApplication] canOpenURL:direct]){
[[UIApplication sharedApplication] openURL:direct];
} else {
[[UIApplication sharedApplication] openURL:web];
}
Is it possible to post a message to twitter using twitter app installed on device and automatically get back to my app? I can open twitter app with
NSURL* myUrl = [NSURL URLWithString:[NSString stringWithFormat:#"twitter://post?message=%#", sharingString]];
[[UIApplication sharedApplication] openURL:myUrl];
but after that there is no way to automatically get back.
For Facebook there is a nice way to do it with the FBConnect and FBAuth, is there anything similar for twitter?
Why not use the new TWTweetComposeViewController that comes with the iOS 5 SDK?