How to get the language-setting of an iPhone OS device visiting a web page? - iphone

I'm trying to create a web-page intended to be viewed by an iPhone OS device. Is there a way to retrieve the current language or some locale-specific data when a user visits on an iPhone OS device? I want to set the web-page language according to the local or language of the device. So, how can I get the language-setting of an iPhone OS device visiting my web page?

Try using the "Accept-Language" header sent by the browser to the server. It should be something like "en-us" or "fr-fr", etc. depending on the language setting for the device.

iPhone indeed sends reasonably correct Accept-Language as seen from this email.
(However, it's strange for me that it sends only fr-fr. It appears more reasonable to send fr-fr, en-us;q=0.9 and they might change into that in the future)
But the more important information for you is that you don't really need to do anything complicated in your situation. This is called content negotiation and is standard feature of Apache and other servers -- they will automatically return page in the language user prefers with minimum configuration.
You do need to create different pages at different URIs for different languages. If you don't, you're breaking the idea that any content has an URI that can be easily passed to another person and that second person will see exactly the same content even if his/her language is different.
How Apache does it. You create
example.fr.html
example.en.html
example.de.html
(and edit .htaccess file). Then /example returns page in user's language while /example.fr always returns French. As an added bonus, you don't need .html.

Related

Database info not showing when previewing site on mobile?

I have made a simple full stack application that uses a postgreSQL database. When previewing the site on desktop it works fine and is able to retrieve all the information with no problem so long as my backend server is on. I am trying to preview the site on my phone using my IP address followed by the port number and it comes up just fine but only the frontend is displaying on my phone. I am unable to see any information from my backend or database. Does anyone know why that is or how I can fix that to display on my phone (without hosting the site)?
1.Maybe it's just cashing issue.
check your mobile phone browser cash setting.
In general, browsers use caching technology for performance reasons. Caching refers to storing values that you previously requested locally and then reusing old values without using new values when a similar request comes in.
2.Maybe it's a front-end css problem.
If design-related elements such as css are not accurate, problems that cannot be seen on the screen may occur even if server data is imported normally.
3.Or maybe front-end can't get data from the server at all.
In this case, it is necessary to debug the server source, check whether it is sent normally on the screen, and check whether the response is received normally through the network terminal.
After checking the three above, even if you can't solve the problem,
At least you'll know exactly what the problem is.

Flex mobile project for IOS, server side proxy

I am trying to write an iphone app that loads a video from an inbuilt web server running off a camera (connect to iphone via wifi).
I am using flash builder / flex mobile project - not particularly familiar but finding it easier to understand than xcode !!
The files from the camera have the wrong file extension so will not play on the ios video app, can I set up a server side proxy in flex mobile and use this to alter the file extension and then pass this link to the ios video app ?
If so any help anybody could give me ( examples etc) would be really grateful received , I have been trying to get round this problem for a couple of weeks .
Cheers
Toby
I can explain, conceptually, what a server side proxy would do in this case. Let's say you are retrieving a URL, like this:
http://myserver.com/somethingSomething/DarkSide/
to retrieve a video stream from the server. You say it won't be played because there is no file extension; so you have to, in essence, use a different URL with the extension. Set up 'search engine friendly' URLs on the server. And do something like this:
http://myserver.com/myProxy.cfm/streamURL/somethingSomething%5CDarkSide/Name/myProxyVid.mp4
Here is some information on how to deal with Search Engine Friendly URLs in ColdFusion. Here is some information on how to deal with Search Engine Friendly URls in PHP. I'm sure Other technologies will come up in a Google Search.
In the URL above; this is what you have:
http://myserver.com/: This is your server
myProxy.cfm: This is your server side file; that is a proxy
streamURL/somethingSomething%5CDarkSide/Name/myProxyVid.mp4: This is the query string. It consists of two name value pairs. The first is the streamURL. This is the URL you want to retrieve with your proxy. The second is just random; but as long as it ends with the file extension .mp4 the URL should be seen as an 'mp4 file'
The code behind your myProxy.cfm should be something like this, in psuedo-code:
Parse URL Query String
Retrieve Stream.
Set mimeType on return value.
Return stream data
I used a similar approach on TheFlexShow.com to track the number of people who watch our screencast on-line vs downloading it first. I also used the same approach to keep track of impressions of advertiser's banner ads. For example, the browser can't tell that this is not a JPG image:
http://www.theflexshow.com/blog/mediaDisplay.cfm?mediaid=51
Based on this, and one of your previous questions; I am not convinced this is the best solution, though. I make a lot of assumptions here. I assume that the problem with playing the file does relate to the extension and not the file data. I assume that you are not actually streaming video with an open connection on both client and server to send data back and forth.

Password login for ios app

I am currently developing an app for a company that is in a very competitive field. I have finished all of the features of the app that they requested except for one, making it somehow protected from their competing companies to download and use. I thought that I could set up a UIViewController with a password field that would check against some kind of database, but I'm not sure how to do the checking against a database part nor the practicality of it, and was hoping I could get some ideas on how to do this so that other companies couldn't steal and use this app without a password or something that changes like every 30 days or something and is kind of like an activation code.
Review the WWDC 2012 video "Building and Distributing Custom B2B Apps for iOS". I'm unsure if your app is in this B2B classification, it seems that it might be from your description.
What I ended up doing (if everyone needs a reference) was setting up a server with an SQL table that has pass codes in it. Since apple does not allow for any sort of system that requires you to "buy the app from outside the app store" I made a dumby username field (shame on me) that takes any value you like and then requires to have a pass code that fits. Once the pass code gets authenticated with the web server in a json sql request (there are plenty of api's to do this with) it comes back and sends the user to the first screen and sets a value in a plist with how many days of use the user has left. Whenever the user opens up the app it checks to see if the date is different from the last date logged in (saved in the same plist file) and if it is different then it calculates the difference and deducts that many. When the count reaches 0 it sends the user to the pass code authentication screen again. A bit complicated but an effective method of getting around Apple's restriction on not having a sort of pass code system like this. Thanks for the answers, unfortunately enterprise did not work for this company since they needed to be able to distribute the app to as many 3rd party members as they wanted to without having to worry about them leaving the company for other suppliers and remote management of the app (I.e ability to remote uninstall) was also not an option. Hope this helps someone someday!

How to locate any mobile number using iPhone application

I want to make an application on iPhone which locates the mobile number region(area) when the user gets a call. Can anybody give me guideline how to accomplish that task?
You can't access the details of an incoming call on the iPhone.
Crazy idea: User would define a phone number of your server (SIP, VOIP) as "forward when declined"-number. When the user gets a call, he would simply decline it, so it would be forwarded to your server. There you could extract the information and send it to the iPhone (Push Service). And finally you would redirect the call back from the server to the user's iPhone.
For anyone looking for an answer to the second part of this question (how to get the location for a number), there is a similar question (asked interestingly enough one day before this one) with several answers here:
Telephone area code to city name on iOS
I also discovered an SQLite database named calldata.db in the private framework AppSupport.framework that contains US cities, states and area codes, as well as prefixes (the three digits that come after the area code).
Using a query like this you could find out that area code 212 is New York, NY:
SELECT * FROM citycode, npanxx, npa
WHERE npanxx.npa = 212
AND citycode.code = npanxx.rate_center
AND npanxx.npa = npa.npa
I don't however know if accessing/packaging this database would violate any agreements with Apple (I do know that the Default.phoneformat file from AppSupport.framework has been packed with several apps which had no problems getting into the App Store, see comments here: https://stackoverflow.com/a/13116227/381233). Perhaps there are some methods in the AppSupport.framework that would get this information more easily, but that would definitely not be allowed in the app store.
As for the other part of this question (access the details of an incoming call), this would most likely be possible on a jailbroken phone. No doubt there's already a tweak in Cydia that does this.

Open pdf/doc/xls in other iphone app with modification acknowledgment

I know how to implement inter-app communication. I did it with some examples.
Now I need to send/share a doc/xls file with other application in my iPad/iPhone that have url schemes to open in such files.
Questions
How Can I find the list of application that has url schemes to open such files.
How can I limit the open-in in some specified application with in the above list.
Important
How can I prevent the shared document from further sharing (such as email/print).
And if the shared file is modified by that application how can I know it.
How can I get back the shared file after modification.
While sharing is there is any option to make it as read-only,read-write privilege.
In general, it is impossible to prevent a document from being shared. You can only make it more frustrating.
Everything else depends on the URL scheme you are using. For example, if it is the file:// scheme then access is controlled by the OS and filesystem. If it is the http:// scheme then access is controlled by the HTTP server, etc.