iOS-Facebook connect with UIWebView - iphone

I am a beginner in iOS programming. I am trying to build an Facebook app using iOS SDK for facebook. I have downloaded and integrated the facebook SDK with my sample app. I have also created my app id. I am also able to start my app by (after facebook object creation):
[_facebook authorize:#"123456" permissions:_permissions delegate:self];
Here user authorization takes place within the default iphone browser.
After successful user authorization, I am trying to pass a facebook url pointing to a particular person's facebook wall, within a UIWebView. Now the problem that I am facing is that UIWebView opens up the url in which Sign In/Login option is again there, which should not be the case as I have already done the facebook authorization part.
So my question is how to pass the active facebook session within UIWebView, so that the authenticated user can straight away open any facebook url within UIWebView.
Strangely, instead of UIWebView if I use the following code to connect to a facebook url , i am allowed to successfully connect as an authenticated user:
NSString *url = [NSString stringWithFormat:#"http://www.facebook.com/xmarshall123"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: url]];
The above code off course opens the default browser, and that's probably why I am able to connect to the facebook url as an authenticated user.
Please help.

Related

How to get/view/read the current URL is in Safari?

Did lots of searching, just came up with the "how to open a URL in Safari..."
Looking to find how to get/view/read what the current URL is when Safari is opened.
Edit:
My app opens a URL with Safari as follows:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:myURL]];
Supposidly, after some validation from website, the ending URL has some attached info.
So I'm trying to get that final URL from Safari.
This is not possible, you do not have access to any outside app. However how most of these authentication / validation techniques work is (like facebook / dropbox login etc.) is that they use some kind of callback back to the app.
You can register an specific url scheme to your app which can have parameters, this way you can get the info in the url the you need. The website will need to support callbacks though or you would need to be able to access the website to provide it yourself.
On how to work with URL schemes you can check out this tutorial:
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-working-with-url-schemes/
You cannot view this information, as the other posters have said. What you need to do is to use your own website to match the user of the app to the user on the website.
For example, you can send a random number to your website when the user is sent there buy.php?id=123445. Then request (periodically and/or with a button press) via the iPhone the result from your website ex. check.php?id=123445.
This also could be done with cookies and php sessions.

Facebook button going to facebook iPhone app, but not loading correct facebook page [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Custom URL scheme for new Facebook iOS app
I have a Facebook button in my iPhone app. When it gets touched I want it to go to the Facebook iPhone app and load a facebook page if the Facebook iPhone app is on the device, if not, then go to Safari and go to this facebook page. The code below takes you to the facebook app, but it just goes to the feed. But it works how I want it to when the Facebook iphone app is not installed
This code does get run.
How can I go straight to the page from a click of the button?
NSString *urlStr = #"https://www.facebook.com/MYFACEBOOKPAGE";
NSURL *url = [[NSURL alloc] initWithString:urlStr];
if (![[UIApplication sharedApplication] openURL:url]) NSLog(#"%#%#",#"Failed to open url:",[url description]);
Maybe try using this instead.
https://apps.facebook.com/YOUR-NAMESPACE-HERE
I can access my own canvas app with the above URL, but using www. doesn't work.

How to return to app after openURL

in my app I need to open a url by using
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"urlstring"]];
after a certain process in the page how can i return to the app.(like facebook doing for safari authentication)
You can't unless you also build the website part, then you can open your own app by calling the App custom URL scheme, wich you will have to add your self to info.plist.
What the Facebook app does is it registers fb:// URLs to redirect to it. Then it sends you to a special link at facebook.com that redirects to an fb:// link while passing some information along (a token or whatever). If you open Safari and type "fb://" into the URL bar you'll get sent to the Facebook app. rckoenes' answer shows how to register URLs to do that, but the part about returning to your app is up to your website (you have to write that redirect page).
This might work?
UIWebView webView = [[UIWebView alloc] init];
NSURL *url = [NSURL URLWithString:#"urlstring"];
[webView loadRequest:[NSURLRequest requestWithURL:url]];

Can I open local file url with Safari by Application::openURL method in ios?

I need to launch a page in my ios app, but want it to be launched outside of my app, because this page will redirect user to a bank page to pay.
I do not have the direct Bank URL on hand, all depends on the redirection action.
I 'd like to open it with Safari outside of my app, in that case, the bank url address will be showed, app user will feel secure.
Embed a bank page in a UIWebview looks not good.
is that possible, how can I do this?
Try this one:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: #"https://www.mybank.com/?shop=pipco&customer=rdnzl&product=muffin"]];

Anyone know how to open a fb fan page in iphone app from web page?

I'm trying to open my facebook fan page in the fbook app from a web page in safari.
I found
What are all the custom URL schemes supported by the Facebook iPhone app?
and I've tried setting the link to
fb://pages/[pageid]
fb://pages/?id=[pageid]
fb://page/[pageid]
fb://page/?id=[pageid]
fb://profile/[pageid]
They all open the app( of course ) but not at my page,
I feel like i'm close but I've been poking round at it for a while now, any help much appreciated.
To open facebook page in facebook app you should:
1)Find uid of your page (it can be done for example by looking at source code of your facebook page)
I got the following fragment from the source code of the page: http://www.facebook.com/Innova.et.Bella
{"text":"Innova et Bella","type":"ent:page","uid":73728918115}
N.B.: To check if uid is correct substitute uid for pagename: http://www.facebook.com/73728918115
This url should open your page.
2) When the uid is found end is correct use this code:
NSURL *urlApp = [NSURL URLWithString:#"fb://profile/73728918115"];
[[UIApplication sharedApplication] openURL:urlApp];
This code will open you page within facebook app.
N.B.: Do not forget to check if the facebook app exists( or more precisely that the url can be opened) using: if ([[UIApplication sharedApplication] canOpenURL:urlApp]) otherwise open it in Safari.
Facebook tab pages do not displayed in the mobile or app version of facebook. Not possible.