I'm upgrading a Cordova iOS 5.1.1 application (written still in jQuery) to iOS 6.1.1 platform as Apple rejects apps that still use UIWebView. I find the migration quite tough as my app is using loading JS files via Ajax, storing data in localStorage and storing PHP Session cookies and all of this data must be reachable now as well.
I have added cordova-plugin-migrate-localstorage plugin to migrate the localstorage data that UIWebView was using and it works fine. However, I cannot seem to find / implement a solution how to save cookies, especially PHP Session ID as it's mandatory that it doesn't change for each request, because PHP backend returns data depending on the SESSION data.
I've tried most of the plugins that were mentioned, for instance cordova-plugin-cookie-sync, cordova-plugin-cookie-inject etc. but none seem to work and store the Session ID.
Unfortunately I can only test the app in the simulator as none of my devices has i so I'm also wondering if there is a solution that doesn't demand having a physical device?
Am I doing a mistake and should stay on iOS 5.1.1 platform and just add wkWebView? I tried to play around a bit and just add the wkWebView Engine to it but it doesn't seem to know how to load local JS files.
Related
I am using Ionic1 with AngularJS.
I asked a question a few days back to fix an issue I had with PHP session variables which will give a deeper look into what I have done in my code:
PHP $_SESSION variables not working in ionic/angularjs application
My Issue:
I was developing it on Android and now I am developing it for iOS. What I have done is ported my files over to a mac and created a new platform (iOS) via ionic/cordova commands for my app. Both the android and iOS version of my app uses the same code and points to the same set of server/PHP files.
On the android version, it seems to keep the PHPSESSID the same throughout, from logging in and going into different pages with HTTP requests but on the iPhone simulator on xCode it doesn't seem to. The PHPSESSID changes on each HTTP request.
An example:
In my login.js I do a $_POST request to validate login details. If correct, move $state to menu.js. In this file, I do 3 separate $_GET requests to get data to be used in the app. When I inspect this when using an android emulator/browser it displays the set-cookie: PHPSESSID and it is the same for all requests while on the iOS it has a different PHPSESSID per request.
I've looked through a few stackoverflow questions:
PHP cookie is not staying set in uiwebview
Keep losing php session cookie in UIWebView
Can I set the cookies to be used by a WKWebView?
But I don't quite understand the answers and I'm not even sure if the answer applies to mine.
How come the iOS emulator doesn't work even though it is using the same files as the android platform?
I am creating an app which is to be hosted in an multi server environment . My frond end is php and backend is java. i am calling everything using rest client. so i want to reduce the number of api calls. For that i need to store the relevent information on client side once it is called once. i dont want to call same api twice(like user profile info). so what is the best option for this ?
Earlier i thought of using session, but i hope that wont work out for multi server enviornment. I dont have a database in frontend.
so can i use cache for this ? can cache be used to store user related data?
is cache reliable for this use?
If you are using REST you can cache the API calls themself by using a cached HTTP-Proxy to connect to the REST Server.
I use html5 + css3 + jquery mobile to built my mobile application. Actually I've already desktop version, and i want to make mobile application.
Is that true php wont work on html5 for mobile application?
If that true, i use ajax for call my JSON (that place create on jsontext.php).
I tried HTML5 on desktop browser and it worked.
I built it to apk using build.phonegap.com and install the apk to my device.
After that, my database record not showing. Maybe it didn't execute.
Other user in stackoverflow said we can use backbone.js. how-to-access-a-remote-database-from-jquery-mobile-application
are my steps right? or I have to use backbone.js. THX.
Here's some answers:
Yes, php won't work in a mobile native/hibrid mobile application,
because php needs to be interpreted by a php server before
generating output.
Its easy and simple to both generate and parse JSON, it's widely
used in apps.
That is good. If you want an 'online-only' kind of app, you can use
a webview and point it the url of your app - its basically a browser
without navigation buttons and user interface - but something's
don't work that well, you should test before. It may also display
your app as sluggish and unpolished.
No problem with that, Cordova/Phonegap is actually becoming a very
good mobile framework. You should also install ADB
(http://developer.android.com/tools/help/adb.html), ADT
(http://developer.android.com/tools/help/adt.html) and the Android
device emulator
(http://developer.android.com/tools/help/emulator.html).
You must be sure on how to insert and retrieve dabatase records.
This depends on how you programmed it. Be sure to have the database
available publicly (accessible only from the apps, though).
Hope I've answered your questions, and that it helped.
My website works fine for web browsers that go to my login-protected API pages. However I am making an IOS program that needs to access the API (raw POST, not UIWEBVIEW), but I don't know how to:
A) give the iphone a session id, and
B) send that session id to the server to access the API pages.
I assume this is what needs to be done to access API pages that require a sesssion/cookie...
Note: I did not use any CI session library - made my own. CI stores the sessions in a file cache, not the db.
Here's a tricky one.
I'm developing a web app for iPads that will be installed as kiosks. The app is essentially a quiz. Wont need to store data in a database, but will need to process data from 1 page to another page (from questions page to results page).
Original solution was simple PHP. I have now been informed that wi-fi/3g will be unavailable to the kiosks, so they wont have access to the webserver w/ php that has been working like a charm. App needs to be browser-based.
Looked around for solutions for installing PHP on iPad, like PHPPOD from Cydia, but unsure if that is even an option for iPad...and we wont be jailbreaking them. Can this even be done w/o php?
If you won't be jailbreaking them, trying to get a working PHP interpreter on them might not be impossible, but it'll probably be at the very least annoyingly difficult (and it's unlikely Apple would approve random PHP interpreters in their app store).
I'd suggest trying to port the app to Javascript instead. If it's just a simple questions -> results flow, writing a basic Javascript web app with jQuery to help out if need be shouldn't be too painful.
If you're not jailbreaking them, then you will NOT be able to get any un-approved apps onto them. Apple does NOT want you to bypass the app store, because they want their 30% cut. Installing a PHP interpreter on an iphone/ipad would allow you to build apps outside of Apple's control - this is THE main reason why Flash will never been on an iphone - it's not just for playing movies, it's actually a pretty full runtime environment.
You could try using HTML5 local storage, or use the native SQLlite database in iOS.
Without wifi/3G you would need local storage won't you? For this you need not jailbreak your iPad & force it to work through PHP. You could do that following -
Jailbreak the app & maybe try to get your PHP solution working on iPad.
Build a native app with local storage (using sqlite or core data) & handle the display through UIWebView.
Build a HTML5 app with local storage is easy to do nowadays, again UIWebView would be used.
As Amber suggests, you could build all your quizzing logic in javascript, but I am concerned here as to where you'll store data. You need to refer to point 3.
Hope this helps...