PhoneGap: get back to index.html - iphone

I want to use an external service in my PhoneGap app for iPhone.
The service take a success url to redirect user to the original page when the process has been completed.
What url should I pass to the service to get back to my PhoneGap app?
I have tried with file://www/index.html, but I get permission error.

You can't use absolute urls reliably in PhoneGap html pages. On android you have
file:///android_asset/www/index.html
but on iOS your url is something like
file:////var/mobile/Applications/[uuid]/[app name].app/www/index.html
You don't know that url in advance, so to get an absolute link to index.html you will need to get that url from document.location and either set it as the base url or save it for use in links.

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.

How to get the direct link to a facebook iFrame url?

I have a app which url is like:
https://www.facebook.com/Foo/app_123456789
this app is running in a iframe and loading some urls of my server. At the start the user see a page like[1]:
www.foo.com/index.php
but in the app you also get pages like[2]:
https://foo.com/foo1/test/Tab/New/12345-6789
now the question:
is it possible to get a link which start with facebook.com/... and directly lead you to the [2] url?
Yes it is possible. You can add an extra variable to your URL like so:
https://www.facebook.com/Foo/app_123456789?app_data=any_string_here
Facebook will then send whatever inside the app_data variable to your iframe inside the singed_request. So all you have to do is to check for its presence (and value) and redirect the user accordingly.

OAuth facebook pagetab app error

I'm totally stuck on this one..
I cant get js sdk or even the oauth link working..
When I try the oauth example, it works just fine:
https://www.facebook.com/dialog/oauth?scope=email,user_birthday&client_id=123050457758183&redirect_uri=http://www.example.com/response/&response_type=token
but in my case:
https://www.facebook.com/dialog/oauth?scope=email,user_birthday&client_id=317872318261965&redirect_uri=http%3A%2F%2Fwww.facebook.com%2Fpages%2FDigiComm%2F185749568187479%3Fsk%3Dapp_317872318261965&response_type=token
the link is basically the same, but get's an error
I've been fighting with this for days.. And can't understand, what could be the problem,
because each time i try to open the auth dialog with js sdk i get this same error..
It must be an error in the app settings on facebook side, but i cant understand what..
I'd say i have the same problem as this guy..
but as i can see he hasnt gotten any answer too:
Using OAuth dialog for facebook app do not allow to use canvas URL as redirect_uri
You need to make sure that the canvas/tab/website URL's in the developer app (https://developers.facebook.com/apps/317872318261965) match the redirect URI in your url.
At the moment, your link is pointing to http://www.example.com - you need to point this to wherever your app is hosted.
try to add http://www.example.com/ with all the slashes as website and example.com as app domain
Update:
If it is a canvas app your redirect_uri should be:
urlencode("http://apps.facebook.com/MY_APP_NAMESPACE/");

Facebook Canvas App not loading my URL

I got a page at www.somedomain.com/facebook/index.html http://www.somedomain.com/facebook/index.html. I'd like to serve that via the apps...so via the canvas but when I point the canvas url to this directory (www.somedomain.com/facebook/) I get a page not found error on the apps page. However, hitting www.somedomain.com/facebook/ http://www.somedomain.com/facebook/ does serve index.html in a browser. Any clues as to what's going on here? Might add...there is no https page setup as yet. This is just a static HTML page that I'd like to serve via apps.
Thanks!
In order to load your page inside the canvas iframe, Facebook is issuing an HTTP POST request for the URL http://www.somedomain.com/facebook/index.html.
My guess is your server only serves pages requested using GET.

facebook apps redirect to hosting url in the first usage

I built a facebook apps from an tutorial with using adobe flash builder 4.5 . It is hosted on heroku.
This app gets name, image, birthday and status message . It displays these infos in the screen. And you can also post status message to your fb account. As you understand, it is very simple apps.
In the first usage of this app, after permission dialog, url is redirected to hosting url.
When you want to use it again, You can use it on facebook.com
do you have any idea why it is redirected to hosting url in the first usage after permission dialogs.
Thanks,
cergun
Selam Ceyhun,
This is expected behavior, what you can do for this is simply:
<script type='text/javascript'>
if (window.top.location == window.location)
window.top.location = 'https://apps.facebook.com/myapp';
</script>
that's it.