iOS Safari localStorage broken QUOTA_EXCEEDED_ERR - ios5

While running HTML5 app I have ran into QUOTA_EXCEEDED_ERR exception. After some investigation it has become clear that
(errors were discovered from debug console)
1) every site which tries to use localStorage.setItem experiences same problem (I tested some sites like gmail etc)
2) another proof that Safari has some problems with localStorage/QUOTA is seen when browser tries to load JS file which size is 81Kb (little bigger than average). This causes "Parser error" exception and it feels like Safari doesn't fully load it
iOS version is 5.0.1 (iPad2 hardware)
What can cause this localStorage problem?

I have found out the reason of such a strange Safari's behavior: private browsing mode. Every app that uses localStorage should check window['localStorage'].setItem for rising exception before using it.

Related

URL fails with NSURLErrorDomain on iPhone, works fine in simulator

I've got some code that is retrieving JSON data from a server on the 'net. I have tested extensively in the simulator with great results. However, when I run the exact same code on my iPhone (simply switching the target device) it fails with NSURLErrorDomain, -1003.
After a little googling I found that this is a "CannotFindHost" problem. So I simply copied and pasted the URL into MobileSafari on my iPhone. Sure enough, it doesn't work, Safari states that "the server cannot be found". Typing the same URL into Safari on my MacAir works fine.
So apparently the URL lookup is failing on the iPhone but not my laptop. This is very strange, considering that the iPhone is connected to the laptop, that is is on the same WiFi router.
Now, ready for this?
When I turn off WiFi on the phone and use LTE, it works perfectly.
I cannot imagine what's going on here. I'm getting reports of this same problem from the field too. Can anyone offer a suggestion on why this might be?
Well I'm not 100% sure what's going on, but it appears to be limited to certain iPhones. People downloading the app fresh in the last day or two have no problems.
That seems to imply there's a cache on the iPhone that is the issue, and that it's cached on a per-connection basis.

Why can't I use the Javascript Log console properly with iOS 7?

I desperately need to use the Safari console on iOS 7 to debug a site. I've hooked my iPhone (5) displaying the site to my Mac. I've started Safari (v6.0.5), gone to the Develop menu, and started the web inspector for the site I'm on. I can see the list of elements on the site, which confirms I'm inside the correct inspector.
From what I've read, the logs to the console should be displayed inside the Logs section, and from what I've found inside Apple's iOS Safari documentation, I should be able to view logs inside there. For me though, nothing is ever logged. I can't even access any variables or functions; when I type anything in (e.g. document.title), it just 'logs' exactly what I've written, with the text I've just typed still in the input field. However, typing something that causes the browser on the device to show life works (e.g. alert('hi'); displays the alert dialog box on the device).
Can anyone help? This issue we have is only happening on iOS, and there's barely any other way to find what's going wrong. Is this problem limited to iOS 7?
I can confirm that this is an iOS 7 issue. The console.log statement works fine when using an iOS 6 or below device, but with iOS 7 won't show at all :(
Apple == new Microsoft();
Only minutes after posting this I got logging to work again, not sure if this is required, but it seemed to do magic for me:
Connect iOS 7 device
Open XCode
Setup device for development
Connect using Safari
Presto, I can see log messages again?!? (Mind you, I had not made any code-changes)
I had the same problem, just after updating to iOS 7. The solution was to update safari to the latest version for developers, which is version 6.1.

Adding a NETWORK section to HTML5 manifest file and accessing iPhone web-app in airplane mode

The facts
I'm building an HTML 5 responsive website with an offline mode. To do that, I'm using a manifest file with a FALLBACK section and the browser's localStorage to store the pages that the users decide to save for offline access.
Everything is working great both on desktop or iPhone (haven't tested it on Android yet), except when I add a NETWORK section to the manifest file.
Why do I need the NETWORK section ? I need it for Google Analytics to work - otherwise my website's users won't get tracked, even if the user if online (that's how HTML5 applicationCache works). So this really is mandatory.
On the desktop, this is not an issue, I can turn off the Internet connection and the website works in offline mode.
On the iPhone, however, if i'm turning off the Internet connection (for instance turning on airplane mode) I'm not able to start the web-app (meaning my website added to the home screen) once the NETWORK section is added to the manifest : i'm prompted by iOS to turn on the Internet connection, and the app is closing. If there's no NETWORK section in the manifest file, everything runs fine.
My question
is twofold :
1) while I can understand that there is some logic behind such behaviour, it seems very strange (well, almost unbelievable) to me that you can't have an iOS web-app working in offline mode if there is the slightest attempt to access the network - I've read numerous tutorials about applicationCache on iOS and no one ever mention the NETWORK section's incompatibility with airplane mode.
So, does anyone can confirm (or infirm) what I'm experiencing ?
2) If there is indeed such incompatibility, the only workaround I can imagine is having a dynamically build manifest file server-side, adding a NETWORK section for desktop users only - but that means forgetting about tracking mobile online users, which is not acceptable.
So, does anyone have a better idea ?
Oops, I should have looked better on SO : this has already been answered here :
https://stackoverflow.com/a/6285955/2251905
Following the steps outlined in the abover answer solved the problem.
This has nothing to do with the NETWORK section (thankfully and rightfully !), but with what seems to be an annoying iOS bug on the iPhone.

cordova/phonegap 1.6 crash at second launch

i use xcode 4.3.2 with phonegap 1.6. my app runs well the first time, but if i close the app in the ios simulator and i launch it for the second time, it crashes. Why?
This is probably only in the simulator. I have had it a couple of times in the simulator but it never happened to me on-device.
I am currently having this issue, except in Android. This is with the release flag. More info can be found here: https://forum.ionicframework.com/t/v2-android-second-app-start-doesnt-work-for-release-version/125583
but here is a copy pasta in case the link goes down:
Synopsis:
My app has a canvas on it on the page html. On second start of initial install, app start doesn’t show canvas. I know because the body tag has a background and the canvas has a different background. The page does not have a module defined for it. This is only when built with --release
Environment:
Ionic: 3.20
Cordova: 7.1.0
Angular: 5.2.9
Android: 6.1.2 (I think build target 25)
jdk: 1.8
Additional Info:
I am sort of doing bleeding edge stuff, but I am now out of the realm of being able to solve this on my own. I am using pixi.js, specifically from an additional interface library called angular2pixi. A2p doesn’t support --aot building.
Before I go on, let me reiterate everything works, even on multiple app restarts for everything other than --release.
The top level architecture is fairly simple:
a2p provides a service that has an instance of pixi. My app uses that service and has a page with a canvas awaiting Pixi’s rendering. When the app initializes, it starts up the pixi service, passing it the canvas reference and voila: html5ified angular.
I have offloaded the actual initialization of the rendering to a user clicked button to make sure it’s not something to do with life cycles but that didn’t work either. Even more interestingly, the button I made didn’t show when the app didn’t load. So likely, this means the ion-content itself isn’t showing!
Most interestingly, if I go into app info and delete storage (not cache) then it works on next app start! I am using localstorage but I attempted removing all mentions of it and no luck. ALSO On second install, or rather what would more technically be an update, the app works on every start after that.
This happens on android and I can’t seem to replicate it in iOS other than the first time I tried. Because it is a release build, it’s difficult to debug. I attempted using Ionic Pro Monitoring to no avail.
So far, my leanings are:
some type of caching causing a bug with the canvas itself
an error that is causing cordova or ionic to terminate
problem with my build process
a2p’s architecture (how could I go about debugging this given I have little knowledge of the underlying mechanics of cordova/ng2 -> native compilation?)
a cordova plugin (perhaps causing one of the above)
So as you can probably tell from my formatting, I’m somewhere between nerd heaven and hell. Such a fascinating problem… but plis halp

iPhone SDK - UIWebView embedding a YouTube Video

I am using this to prevent the app from opening the youtube app and instead plays the video whilst staying inside my app.
It works fine and all but it's a bit slow with loading it's date (they're inside a tableview, each cell for about 15 atm~).
The moment when it suddenly loads everything correctly is when this error has been passed into the debugging console:
warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1.2 (7D11) /Symbols/System/Library/Internet Plug-Ins/YouTubePlugin.webplugin/YouTubePlugin" (file not found).
Is it possible that this slows down
the loading of the uiwebview? (as
soon as this error's been passed it
suddenly quickly loads all the
content).
If it doesn't slow anything down is it something my app could get rejected on?
Thanks in advance
you ever find an answer for this? i'm having the same issues
EDIT: this delay is only experienced when debugging on the phone. the plugin attempts to load and there is a large delay before the youtube view pops up in the webview. if you unplug the phone from xcode (disabling the remote debugger) it immediately loads the webview
The warning is there because the youtube plugin used by your device does not exist in the simulator (indeed, the youtube app is not present in the simulator either). The delay you experience is due to continuous polling of the debugger for info from the original plugin in your device.
I'm not quite sure I understand your problem. However, the three20 library has a nice youtube control for embedding in applications.