I am hoping for some help regarding an offline iPad application.
I have a form within the app that the user fills in, this form then links to a PHP script online. Obviously you can't run the script until you are on line. Is there any way at all of clicking the form submit button, if there is a connection it will connect to and run the PHP and if there is no connection it will automatically run the php in the background when a connection becomes available.
I have tried a number of different searches but have still been unsuccessful.
Thank you in advance!
It most likely is possible to solve this problem with JavaScript, but that's not so straightforward. Since you are dealing with an iOS app where it is possible to check network connection status and listen for changes, you probably should create a service that receives the form data within your app. That service should store the data locally, find out when your target server is accessible and send it.
UPDATE:
If you are dealing with a web-app, the way to go for it still to implement a service in JavaScript that uses timed events (i.e. setTimeout() or setInterval()) to check connection status. Upon submitting the form, prevent the default behaviour so the form is not submitted traditionally. Instead, store the data locally in sessionStorage or localStorage and when your service finds the target server available, read the locally stored data and send it via AJAX.
Related
I'm writing a app in ionic. The app relies on external api's.
I've made multiple functions to test the connection, to my own server, and my own server handles the api calls. My own server is needed for this because of ip-whitelistening.
All works well, but now i want to disable the application if the result from my own server is false. I make a call to test the connection everytime the app starts.
What is the best way to handle this with angular/ionic?
1 thought i had myself is to redirect to a landingpage, if no connection is available.
Any tips are welcome.
Yes, basically what you planned to do is OK.
So, just after your app loads up, check if the connection is available (you can read more about how to do that in my detailed post How to check network information change with Ionic framework), and if not then you can change the state to some page where it would clearly let the user know that "Currently the link to the server is not working" (or some better notification).
Also, probably you would want to put a refresh button on that page, so that one could click it and the whole availability process would be checked again (basically same as if someone restarted your app).
Hope this helps.
I am developing a website and i am having a problem in finding the best solution to maintain user login session.
Currently i am using Html5 web storage "session storage" to store whether user is logged in or not. But problem in this is that this only works in a single tab not across multiple tabs of a browser.
What should i use either Cookies or LocalStorage or i should maintain server side session and check every times a page loads on server whether the user is logged in or not ?
What is the best solution? please guide me.
I am using Node.js and mongodb in the backend and Angular and jquery in frontend.
First thing you must know is that sessions are made only for server-side not for client side. Second thing, if you want your user to not load everytime, try to save the data in user's cookies also don't think about it will require more time to load on server. Because sessions are only made for security purpose and i guess by storing them on client side you are not using that purpose. Also now major question is how to store them on the server side. Suppose your server goes down now all of your sessions will get deleted. Now to avoid that use some external data store like connect-mongo/connect-redis. redis is faster than mongo but if you want to use only memory store then search for memcached/cookie-sessions/jWT hope this answer helps :)
I've been toying with writing a web app using jquery mobile which makes use of forms (cehckboxes, text fields, combo boxes). The tasks the app requires are fairly trivial but the information needs to be updated and sent to a server.
So my question is, say someone uses the app, gets a bunch of data from a server, then loses connection. Will the browser still remember the form fields input and could the user still navigate between pages? From my understanding jquery mobile places all its pages in the same 'webpage' so it's not like it will have to be constantly loading up new data from the server.
My idea is that I'll run some script in the background to check for a connection to a server and when it gets this connection it can go ahead and sync data with the server.
Is this possible or is it a pipe dream?
for jquery mobile it append all the data it had in same page so user can use only those links which are already clicked for the links that user have not touch yet will create problem
I am creating a chrome extension, rather a chrome webapp. This application just contains the html, js, image and css files. The application connects to a server to fetch data. I chose to do this as it would reduce the amount of files downloaded by the user. Using Backbone.js I have an MVC architecture in my application. Thus the application just sends json.
Now having said this, I need a session management. I plan to use Google authentication as the organization has Google Apps. I need a method that once the user has logged in using google auth the server get the user name every time the application makes a request.
Is it a good idea to add the user name in request header, if possible. Or should I use cookies? Can any one tell me how I could go about using cookies in this case?
This might be a late response but I want to present a more elegant solution to you given that the user has cookies enabled in their browser.
First read my answer on another question.
Now that you can send cross origin xhr from your content scripts all you need to do is store all your authentication and session management at server only. That is right, you just need to display whether the user is logged in or not and a logout button at client based on server response.
Just follow these steps.
At client Whenever user accesses your chrome web app, blindly make XmlHttpRequests to your server without worrying about authentication, just keep a tab on response from server which I describe below.
At server whenever you receive a request check for valid sessions or session cookie. If session is valid send proper response, if not send error, 401 or any other response to communicate to your client that session is not valid. It is better if you send an error code like 401 since then you can put a generic script at client to inform them that they are not logged in.
At Client If response from server is proper, display it, else display login link to your website.
IMPORTANT: Display logout button if user is logged in.
Check out my implementation of this in my extension
For help using Google authentication in your app take a look at Google's OAuth tutorial which comes with all you need (took me no time to set it up using this).
As for session management. The implementation of OAuth used by Google stores the tokens in localStorage. Also, as briefly mentioned in the extensions overview we are expected to use localStorage to store data. Thus, I suggest you store the users name here as it will be accessible throughout the app's lifetime (until it is uninstalled). However, you may need to manage the name stored here and consider what should happen when users log in and out. That said; I'm not sure if sessionStorage would be a better option as I've never used it before, let alone in an extension.
Note
localStorage and its counterparts only store strings so I suggest using a wrapper which uses JSON to parse and stringify to get and set your values respectively.
I have a kiosk web page that users use to sign in at an event.
On the page there is a form with a name and email input.
To prevent slow responses due to connection problems I have set up the ui to send asynchronous ajax posts.
The problem is that the connection may not be available, but I don't want to lose the data that was submitted (if the browser was accidentally closed for example). What is a way to go about saving the form data and auto retrying sending it when the connection is available?
Is this a paradigm that exists or would I have to write a full solution myself?
I was considering using HTML 5 persistent storage.
You could use evercookie or some of its ideas for storage