Where would localForage data be stored for an iPad app? - trigger.io

I understand how localForage works in unison with a browser, but am less certain how it would interact as a part of a hybrid iPad app. There is no browser, per se, to store data in so I'm wondering if using localForage will still allow my data to be available offline.

So are you familiar with what a 'Hybrid app' is?
Not to be an a-hole about but a hybrid app, by definition is a 'web view' in a wrapper. Cordova, trigger.io etc are all basically doing the same thing. Taking the native browser ( IOS and Android ) and wrapping it in the context of an 'app'
thats the short version, you can read a lot more about it online, anyhow to answer you question about localforage..
LocalForage is a 'shim' meaning its uses what ever the platform will support, so for IOS below 9 ( I think ) it will use SQLLite and over IOS 9 and above it will use indexDB. With Android and crosswalk it will use indexDB ( unless otherwise selected )
Now for devices that do not support one of the other it will fallback to localstorage but that is limited due to the total size of storage

Related

iOS UIWebView and Cookies storage

I use Cordova 4, Angular 1.4 and Ionic 1.3 to make a tablet app for Android and iOS.
When user synchronised datas, app opened another window (cordova-plugin-inappbrowser) and displayed our SSO webpage. When user ended to connect, window was closed and synchronisation was send again.
Android store session cookie when app is closed but iOS don't.
Each time user open app on iOS, he need to open window authentificator.
Is it a way to store much longer cookies on iOS ?
Thanks
EVURLCache may help you.
This is a NSURLCache subclass for handeling all web requests that use
NSURLRequest. (This includes UIWebView)
The EVURLCache is meant for handeling the following caching
strategies:
The app has to be functional even if there is no internet connection.
The app has to be functional right after the app has been downloaden
from the app store. (This means that the required content can be
included in the app.)
You do want to be a able to download new/updated
content if it's available.
Note:
Support: iOS 8+ OSX 10.9+ WOS 2+ TVOS 9+

Don't need the App Store to make apps anymore?

I recently found a site that allowed me to bookmark the site and then use it just like an app. There was no url bar, it was indistinguishable from an app you would download on App Store. Is this a new upgrade or technology ?
This is not new technology, I don't remember how long it's been out, but I'm pretty sure at least since iOS 3. It's called a webclip. You can do quite a bit with a webclip but are still limited to functionality provided by JavaScript, so no accessing the flashlight and certain hardware features (although many are being included in the device JS object). Though it is certainly much easier to implement basic app functionality!
+1 to SnoApps and here's a bit more detail about this older detail.
You can specify a webpage to appear like a regular app icon on the iPhone "home" screen (where all the apps appear).
There's more information here under the "Configuring Web Application" section of this Apple Safari Web Content Guide.

iOS 7 webview and localStorage persistence

I'm developing a hybrid app (for iOS and Android only) using PhoneGap/Cordova and want to use HTML5 localStorage to store content for offline access.
http://caniuse.com/#search=localStorage says - "In iOS 5 & 6 localStorage data is stored in a location that may occasionally be cleared out by the OS."
What is the situation with an iOS 7 (and later) webview, in what cases will localStorage persist, or get cleared out (by the OS, or the user)?
Will an update to the app clear localStorage?
What about the user clearing browser history on Safari - will that apply to the webview too?
Do I need to worry (or can I even control) where on the fils system the localStorage is created. I understand it should not be backed up on iCloud.
I got a device (iPad) and checking the file system I see that localStorage file is in ~/Library/Caches within the app sandbox, see image below.
From the docs:
https://developer.apple.com/icloud/documentation/data-storage/index.html
Data that can be downloaded again or regenerated should be stored in the /Library/Caches directory. Examples of files you should put in the Caches directory include database cache files and downloadable content, such as that used by magazine, newspaper, and map applications.
I am simply doing this to set data:
localStorage.setItem('foo','this is the FOO value');
localStorage.setItem('bar','and this is the BAR value');
If you do still face the issue with Cordova-iOS v4 , then try the NativeStorage plugin. https://www.npmjs.com/package/cordova-plugin-nativestorage.
It has set, put and get functions which implement platform capabilities like android shared preferences and iOS NSUserDefaults which makes data store as safe as allowed.
cordova plugin add cordova-plugin-nativestorage
NativeStorage.putObject("reference_to_value",<object>, <success-callback>, <error-callback>);
NativeStorage.getObject("reference_to_value",<success-callback>, <error-callback>);
If you are using cordova, that problem was fixed long time ago, even for iOS 5 and iOS 6. You shouldn't worry if you are using the latest version of cordova.
Your best bet is to use the NativeStorage plugin:
https://www.npmjs.com/package/cordova-plugin-nativestorage
To answer your questions:
The localStorage data is kept in a cache directory in the filesystem, and cache is cleaned by the OS frequently (for example when the device is low on disk space).
No, updating the app won't clear local storage.
No, Safari local storage and Webview local storage are separate.
No, you cannot control where on the filesystem it's stored.

PhoneGap in regards to App Store approval

I read that PhoneGap is approved by Apple as a framework for building native apps, but I'm not clear on how this does not constitute a "website wrapped as an app," something that Apple specifically doesn't like, as per their App Store guidelines. I'm assuming it is because the JS is contained in the application, rather than running on a remote server?
Any clarification on this issue would be most appreciated.
but I'm not clear on how this does not constitute a "website wrapped
as an app," something that Apple specifically doesn't like, as per
their App Store guidelines.
By this Apple means Apps that simply show a UIWebView that loads a remote website, so it basically just behaves like Mobile Safari, just without the controls. Also they wan't Apps to show at least a UI when the device is not connected to the internet, like in the Facebook App where you can still read already downloaded status updates, view photos etc. That's what a "I just wrap a remote website inside a UIWebView"-App can't do.
PhoneGap Apps have all the resources they need (HTML, CSS, JavaScript) on the device residing in the App's bundle, so using such an App would not depend on network availability and could at least show a UI that tells you to connect to the Internet in order to use the App, or they could display already loaded content (like Facebook, Twitter and so on).
I think that the signature of the binary tells Apple what framework built the application, and since all the supporting files (js included) are included in the project and therefore in the binary, it is a standalone application. That being said, I still think that doing things Natively is the best way to go. I am extremely comfortable with javascript and started out thinking Phonegap was the way to go for me. I did a couple of projects with it and then decided to take the plunge and learn Objective-C. That worked out so much better for me. No dependency on a third party framework and I wish that I had started that way.
Sometimes the easy way out just hurts ya in the end IMO.

share data between iOS native app and browser app

I am a rookie iOS developer trying to figure out this. Pardon me if I am asking basic question.
I need to set an unique identifier in the device (iphone or ipad) that can be read by the app (can be browser app or native app). Is this feasible ?
Reason being: the device needs to be uniquely identified. The user might be able to use the installed app or through browser as well.
Thx.
You can create a HTML element containing any amount of content and hide it with CSS. Sometimes I use an 'input' element just for that and read it with javascript. I think you use data-uri also.

Resources