TheCocoaProject / cordova-plugin-nativestorage

Cordova plugin: Native storage of variables in Android, iOS and Windows
http://thecocoaproject.github.io/
Apache License 2.0
292 stars 106 forks source link

callbacks don't seem to work on iOS 10 beta 7 #36

Closed cwelk closed 8 years ago

cwelk commented 8 years ago

First I wanted to thank you for the awesome plugin 😄

On iOS 10 (beta 7) the global NativeStorage Object is accessible, along with all documented methods. Unfortunately none of the callbacks get executed.

This example code works in iOS 9 but gives no output whatsoever (web Inspector, xcode console) in iOS 10:

NativeStorage.setItem('sample', 'abc', function () {console.log(arguments)}, function () {console.log(arguments)})

I know it's still beta but do you plan on adding iOS 10 support?

GillesC commented 8 years ago

After my vacation, I will look into the matter. But be reassured that Android and iOS support is a priority for us. So, we will definitely plan on adding iOS 10 support. I will leave this issue open until the support is added.

kristfal commented 8 years ago

@GillesC Confirming this. It seems like the plugin does not initialize on iOS10 Beta 8. This plugin is likely to increase in popularity on iOS10, as tests so far reveal that LocalStorage in a WkWebview no longer persists between app launches.

Also, this plugin fails to compile on Cordova iOS < 4.0.0 due to int conversion.

GillesC commented 8 years ago

Thanks for the conformation. For compiling with Cordova ios < 4 see issue #29.

kristfal commented 8 years ago

@GillesC Cheers, thanks for the tip – I was about to do that same Int conversion myself. Not to pressure you, but do you have any idea when you'll start looking at iOS 10 support?

I'm currently torn between waiting on you to fix this (which is preferable), or going for an alternative option such as webSQL (which is rather overkill for our needs) to make sure we can support iOS10 when it launches.

GillesC commented 8 years ago

I'm currently on a holiday. But tomorrow I can take a look why the plugin isn't working in iOS 10. So by the end of this week the plugin should certainly work. When is iOS 10 be going officially released?

kristfal commented 8 years ago

@GillesC Thanks a lot! I'll wait for you then 👍

The new iPhones will be announced on the 7th, and looking at how Apple handled this before, iOS10 GM is likely to be released for developers right before that date, with a public launch some time within a week after the 7th.

GillesC commented 8 years ago

In iOS the console plugin is needed to use the console (https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-console/). Could you include this plugin in your project and put the output here?

kristfal commented 8 years ago

@GillesC Not quite sure I am following. The iOS console is working without the plugin. Also, this doesn't work either, so this doesn't seem like an issue with the console:

NativeStorage.setItem('sample', 'abc', function () {alert(arguments)}, function () {alert(arguments)})

GillesC commented 8 years ago

This example code works in iOS 9 but gives no output whatsoever (web Inspector, xcode console) in iOS 10

I thought maybe the "no output" was because the console plugin wasn't installed, and therefore no output was printed.

kristfal commented 8 years ago

@GillesC Ok, glad we sorted that out 👍 Let me know if you need any other information!

GillesC commented 8 years ago

@kristfal before I dive in this mess, would you please try the solution presented in this thread? If it works I don't need to go to the hashle of installing iOS 10 etc. :)

kristfal commented 8 years ago

@GillesC That actually fixed it!

GillesC commented 8 years ago

Haha that's just great!! :D Closing the issue now and adding this issue and solution to the "Problems" section.

kristfal commented 8 years ago

@GillesC Confirming that it is working as expected on iOS10. I must say, this plugin is now a godsend because iOS10 wipes LocalStorage on app exit. Thanks a lot for making it 👍

alokrajiv commented 8 years ago

I think all tests are passing on the simulator beta.

alokrajiv commented 8 years ago

@kristfal wud it be possible for you to list what exactly you did so, I cud include it in the faq for others?

kristfal commented 8 years ago

@alokrajiv:

In your index.html that you are loading on app startup, add the following entries to your Content-Security-Policy meta tag:

gap://ready file:

An example of a 'liberal' CSP which should enable pretty much all content (not really recommended) is:

<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval' 'self' gap://ready file: ws://<url to ws endpoint> cdvfile:; child-src * 'unsafe-inline' 'unsafe-eval' blob:; img-src * 'self' data: blob:;" />

Remove what you don't need, and specify <url to ws endpoint> if you use websockets.

jcleyba commented 8 years ago

Will this work for Ionic 2? Adding this to index.html does not fix the issue.

dodomui commented 5 years ago

I'm still facing the issue for ionic v1, any one got idea what to do?