I'm using localStorage in my hybrid mobile app, which is developed using ionicFramework. Everything works fine, except localStorage uncertain behavior in IOS.
It works fine in Android.
Bug Scenario:
App login -> Use App -> Put the app to background
Don't use it for almost 4 hours -> Open the app
The localStorage gets empty. (And the app is logged out because the token from the localStorage is also missing)
Now force quit the app,and reopen it. All the localStorage values are restored and the app is again logged in. (mean missing values are again recovered).
I'm following the standard way to use localStorage i.e.
window.localStorage.setItem('key', value);
window.localStorage.getItem('key');
window.localStorage.removeItem('key');
I also used AngularLocalStorage, but it also had the same problem, because AngularLocalStorage is a wrapper over Local Storage...
Cordova 5.4.1
IONIC Platform 1.1.1
Related
I have a PWA that I've been using perfectly till I updated my phone to 11.3 (introduce Service Workers supports, so in my iPhone it was only a bookmark) and all worked like a charm.
After I've updated to iOS 11.3 I wasn't able to enter to my app because I have an external login (in other domain) so each time I try to open my open this will open a safari browser to make the auth. Before PWA in iOS the external URLs were open in the same open (without open safari). Do you know if this is the correct behavior and, if it is ok, how can I fix it?
Thanks!
I managed to fix this by removing the manifest meta tag:
<link rel="manifest" href="/tracker/site.webmanifest">
My project is a simple PWA that uses Google's OAuth for login. I was getting redirected to Safari to login and unable to go back to the app (on my home screen). Hope it works for you too, I wasted 2 days trying to find a solution.
The reply by Anand tells me that offline capable PWAs need to implement service workers, since they are supported in 11.3 (or 11.4, not sure) and NOT manifests.
Anyways, this worked for me, hope it helps others as well.
When PWAs without service works(either your browser don't support it or your app don't have one) are added to home screen, its mere a bookmark. When the browser finds a SW, then it creates a package(like apk).
How to test this - Find a PWA site without service worker in android and add to home screen. When I tried it in one of Samsung device, it showed only "Remove" option and no uninstall option. When I added a PWA which had SW, got uninstall option. I was also able to locate the apk generated by Chrome when service worker is present.
Now on iOS - 3 possibilities I could think of.
1) My theory based on above behavior on PWAs with and without Service worker, your home icon create by iOS 11.2.x is a bookmark and the new version of safari is treating it as a bookmark to open it in browser. I couldn't test this as I've upgraded to 11.3 already and don't have a pre 11.3 PWA icon.
2) If you have reinstalled the icon(by removing and adding again to home screen) and still have the issue, its probably because your manifest file or service worker files have some issue/compatibility with Safari.
Since we don't have something like Lighthouse for safari, you can validate your manifest.json and service workers in Chrome Lighthouse.
3) Check on scope attribute in the manifest file to make sure you cover your entire domain you intent to cover. If you scope covers domain.com/myapp only, domain.com/otherapp will be opened in the browser when tried to open from any source.
It seems that with the last iOS version 11.4 this issue is solved, I think that now safari shares the context between the browser and the PWA and for example from PWA cookies can be accessed throw safari.
But I think there's still an issue when you open the PWA and you are being redirect to login (safari opens) once you're log in you stay in the browser (iOS does not return to the PWA, but this is a first step)
Every iOS application has its App Store link, which should redirect you to the App Store on iOS devices.
The link looks as follows:
https://itunes.apple.com/us/app/APP_NAME/APP_ID?mt=8
My application link (https://itunes.apple.com/us/app/storyvine/id929186649?mt=8) works on desktop browser, but gives me an error on iOS device:
iOS Update Required
To view this story, you must update to the latest version of iOS.
However, my iOS version is already the latest one (currently 10.3.3).
The application's name and therefore, the URL starts with the name "Story".
As a side effect of this, the soon-to-be-updated App Store thinks that it's referring to an App Store application story (which is only included in iOS 11 and above) and not an actual App Store app. You should remove the application's name from the link, so it becomes:
http://itunes.apple.com/us/app/id929186649?mt=8
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+
I am creating an ionic app for iPhone/iPad using cloudKit JS in order to storage data in cloud.
I try to authenticate to iCloud using cloudKit JS library. I had converted the Apple's Catalog sample - https://cdn.apple-cloudkit.com/cloudkit-catalog/ to iOS ionic app and Sign in button shows correctly and when press it, it opens a window popup in order to put apple credentials but after that nothing was happening there. Just a loader was displaying and it does not closing and respond back to the app with the user details
When a try this in Safari it works fine.
I am using:
ios: v9.3
ionic: v1.7.14
ionic ios: v4.0.1
Thanks in advance
Could this be a problem with Content security policy and cordova-whitelist-plugin? You need to set those for mobile to be able to load external data.
Whitelist guide:
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist
Content security policy section:
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist/#content-security-policy
I'm using this handy Cordova plugin to set application settings from the homepage of my Cordova iOS hybrid app:
https://github.com/escio/cordova-ios-application-preferences
I have a local hybrid app and from the index.html homepage, and I set an application preference when a user clicks a button, using this plugin.
On success of setting the application preference, I have confirmed via logging that the setting is correctly set. At that point, I call a JS function that looks at the application preferences. What's weird is that although the log indicates that I've set the preference correctly, my JS function is still using/referring to the default value for that preference. If I exit the app and restart it immediately, it's clearly working with the newer application preference but on that initial flow, the app appears to be using a cached version of the application preference.
Any ideas here? How can I get Cordova to use the current application preference?
To close the loop on this, I discovered that although the plugin was setting the value, the hybrid app had a bunch of native code running and the settings values were grabbed by the app at initialization. So in addition to setting the new value in the Application Preferences, I had to add a small method call into the plugin, in objective-c, to set the new value on the native side of the application memory/state.