Cannot set a cookie before redirection - iphone

We have a weird problem in that I have developed a mobile version of our website that just sits in a sub folder of the site e.g /mobile/page.asp (I know .asp classic don't blame me!)
I did want to create two domains one for the mobile site one for the normal site but I was told by our CTO to just do a sub folder.
However the problem is we want to be able to set a cookie that lets us know whether the user WANTS to be on the main site OR mobile site. They could in theory be on a desktop and still choose to go the mobile version (as we have links in the footer to switch views, e.g from the main site to the mobile site and vice versa).
However if someone comes to the site without a cookie set we do some user-agent sniffing do determine their device and then set a cookie before redirecting them to the right part of the site.
All our logic seemed correct however when we started testing it we started getting weird results.
On my iPhone 3gs it was working perfectly (most up to date OS) however on other peoples iPhones or Android phones people would
-clear cookies (at the beginning of the test)
-visit the site
-the agent sniff would redirect them to the mobile site
-but when they clicked on a further link on the mobile site the code took them back to the full site.
This didn't happen for me - also on our demo site it worked for some people and not for others - and also for someone on an Android device who downloaded FireFox it worked fine.
I and another developer who had the problem sat together and went through the steps one by one, doing the exact same thing, with debug on showing us what was going on.
However whilst I was getting a cookie set to "mobile" when I went to the mobile site he for some reason wasn't. It was like the cookie couldn't be set before a redirect even though the redirect was to the same domain.
I read some articles which said there was some issue in webkit with cookies and redirects which made me think this could be the issue on the iPhone Safari browser but that wouldn't explain why my 3Gs phone worked.
We have tried re-working the code but we need to be able to set cookies and do redirects in all cases. We even tried just changing the code that was setting a cookie to a session variable but even that didn't work.
I am really stuck and so is everyone else. We have spend days trying to debug it but cannot find a common denominator which would explain why it works on some devices but not others.
Can anyone help!!! Any advice would be much appreciated.
Thanks!

Related

FB.login() inside inapp browser (no popups)

I have my Facebook login process working on desktop and mobile, except for Facebook's inapp mobile browser (ios and now android). The issue is that if you call FB.login(), nothing at all happens. I assume this is because the inapp browser doesn't deal with popups.
I understand that a redirect auth flow circumvents the need for a login/permissions popup, however I have built a web-app, which means it is a pain to deal with storing the users current state at the point of signing in.
Does anyone have any good solutions for this?
Also I have tested many other sites login buttons through the inapp browser, and all of the ones I have tried so far don't work. Facebook has done a great job of breaking a large amount of sign up processes.
As stated in the comments, that seems to be a bug either in the Android FB- App or in the Android 5 WebView component. There is a bug report at facebook, but they are still working on it. The only solution i could find for now is to turn off the internal browser: http://www.androidpit.com/facebook-disable-browser
Because that action has to be taken by the user itself, it's no satisfying solution. Therefore i guess the only thing we can do at the moment is to stay tuned for facebooks fix.
Update
Facebook confirmed this is a bug. They are working on it. Stay tuned...
2nd Update
Facebook rolled out a patch. Works for me now.

Facebook custom tab not visible to non-logged in users

Pretty much what the title says.
There are tons of questions about this but the vast majority was only a matter of a missing HTTPS URL, a couple are due to misconfigured app restrictions, and the rest are unsolved.
I have no country or age restrictions in my app, I have both HTTP and an HTTPS URLs, I can see the page when logged in as a page admin and everything works fine, but when visiting the page while logged out, I don't see the tab.
Also, this is not a matter of clicking the tab and not having any content displayed, like in some other questions here. If I'm logged in with my The actual tab link is missing and if I copy the tab URL from when I'm logged in and then try to access it while logged out, I am simply redirected to the page.
I don't think it matters much but this is a tab that has been created via the Graph API. The Graph API docs don't mention anything about tab visibility, at least as far as I see.
This is driving me crazy, I've been at it for hours and can't find any solution or even a hint at what the problem might be.
Any ideas?
EDIT: All I described above is happening with our staging application, which has a self-signed SSL certificate. The live application, which has a "proper" SSL certificate, works just fine. Could the self-signed certificate be the cause of the problem?
Had the same issue this morning. Remove any audience restrictions from your app e.g 13 + or location as this means people have to login to see your app.
So it turns out it was stupidly simple: it was happening on our staging application but not on our live application because our live application uses a non-test FB app, while staging uses a test FB app, which is never seen by people who are not developers (or other staff) on that app.
Talk about wasted time...

iPhone/iPad says 'Download Failed' when trying to load website

I have a weird issue. Whenever I do something like login it will create the session, but then say 'Download Failed Safari cannot download this file' and doesn't redirect. If I go the the actual page that it should have redirected me to I am logged in. The same things happens any time you do anything such as logout, upload content, etc.
It only happens on iOS devices in Safari on 3G. Wifi it works just fine. Chrome on the iPhone works fine on 3G. Obviously its like its trying to download something, but I can't seem to figure out why this is, or why it is.
It happens when I am login in to my profile, but if that profile is public and I just go directly to that page without logging in there is not issue. Make sense?.....
The site is built in Codeigniter. If any one has ANY sort of idea that would be great!!!
Set up your device to use a proxy such as Charles. Look for the differences between a successful request/response and a failed request/response.
The problem had to do with a server configuration that was causing the issue. Even thought I had $config['compress_output'] = FALSE; set it was still utilizing gzip. We turned it off in the server configuration and it fixed the issue.

Blank Canvas Page for iFrame App

I'm working on an iframe style app that pulls the facebook optimized page available at http://store.starrco.com/?store_mode=facebook. I've done other, admittedly much simpler, iframe apps before without issue but though I've configured this one more or less the same when I try to view the canvas url it remains blank.
My settings can be seen here: http://www.abstraktmg.com/clients/starrco/starrcofbsettings.jpg
I've tried a few different permutations of this with the same results, this is the most complete setup though and most closely matches the settings template I was given.
This page is being generated by Webasyst's shop-script, which is specifically supposed to support this. The obvious answer then is to contact their support which I did, but after assuring them that my app settings matched their template, they said I needed to contact Facebook support and this is as close as I could find to any proper support system.
I checked both http and https versions of store.starrco.com/?store_mode=facebook and both worked outside of facebook.
However, there may be some framebusting code which might prevent the site from being loaded in an iframe. And I see that your settings appear to be missing the app domain entry.
I ran into the same problem, especially in Chrome and Firefox. The problem is, when the user is surfing with https on Facebook, the https Version of the iframe is called. But the browser do not show invalid certificate problems until you to right click page information.
You need to have a signed SSL cert by a CA trusted in the browser.
If the user has accepted it without the iframe - outside of Facebook, it works.

iPhone: Pass information from web page to app that's downloaded from App Store

I'm trying to glue information from a web page to an iPhone app that said web page suggests to download. I control both the web page and the downloadable app.
Scenario is like this:
User visits my web page, on which I recognize the user (he may have logged in, and I store his info in a cookie). I then present a link to him to an app in the App Store that he should download for "enhanced experience" of this web service of mine.
Now, when the user launches the downloaded app on his iPhone, I like to re-identify the user who previously visited said web page.
All would be easy if an iPhone app could read Safari's cookies. But it can't.
A somewhat lame solution could be that the web server stores the visitor's IP address and uses that to recognize him once he launches the iPhone app. But that's not reliable.
Another one would be to give the user a token (code) that he needs to remember and then re-enter in the app. Still quite awkward, I think.
Any better suggestions?
Simply put, you can't do this.
One thing you could consider is a custom URL scheme to launch the app. You could send the user an email that uses this custom link. However there's a couple of problems with this:
the user may not have the account that they used to register for your site set up on their iPhone. This might seem unlikely, but say the user signed up for your site 5 years ago with their Hotmail account and they have since switched to Gmail.
it's unlikely that the email would fit into their workflow. They would probably download the app and just launch it by touching the icon instead of clicking a link in a received email.
You could also put the custom URL as a link on your web page, but again, this won't fit into the workflow because they have to go to the App Store app to do the download.
Consider this - if you've got some sort of website that has an authentication step, it's probably a fair bet to say that the user is the type of person who already has an application such as Facebook installed on their iPhone. They are already used to the paradigm of having to enter their credentials into an application despite the fact that they may have already done it in Safari.
If you could read the unique iPhone device ID from javascript on your web page, you could look for that again when the application connected...
But I cannot find any means of reading this from Javascript in Mobile Safari, I thought I'd post in case there is a way now to give you another option to consider.
OK, we found a somewhat working solution: The html code can create a cookie. Later, when the app runs, it can't directly read that cookie, of course (due to the sandboxing of iPhone apps). However, it can connect to the server, then open a http URL pointing to the server and including a unique token that it has gotten from the server beforehand. This leads to launching Safari, accessing the server. The server can now read the aforementioned cookie and finally establish the connection with the help of the token.
Just stumbled over this question and I'm curious if you thought about using a UIWebView.
Where the question is - does UIWebView share cookies with safari?
If it does the rest should be easy.
UIWebView's DON'T share cookies with Safari. So unfortunately that is not an option.