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

Fallback for testing in browser. #9

Closed HbIXA closed 8 years ago

HbIXA commented 8 years ago

log

Error: exec proxy not found for :: NativeStorage :: putBoolean
Missing Command Error
alokrajiv commented 8 years ago

are you referring to the fact that you are not able to run in the browser during development.

HbIXA commented 8 years ago

Yes

alokrajiv commented 8 years ago

In the browser there is no preference or 'native storage' available. This is the same reason why many plugins don't work in a browser and work only in the device or emulator. A possible soln would be to have a fallback to localstorage. As of now we don't have a javascript proxy to fall back.

HbIXA commented 8 years ago

I think it makes sense to implement at least a cookie, it is for the browser .

alokrajiv commented 8 years ago

See this ngCordova doc link which specifies testing apps with plugins in general on a browser is not a good idea. It is a common issue with cordova and not specifically this plugin. Same goes with plugins such as media, gyro, camera etc.

GillesC commented 8 years ago

@alokrajiv I'll implement a localstorage approach if the application is running in the browser.

alokrajiv commented 8 years ago

@GillesC Sounds good.

GillesC commented 8 years ago

It'll be a simpel approach: test if in browser, if yes save via localstorage.

alokrajiv commented 8 years ago

I suggest you could check for availability of cordova or phonegap. if not fallback to localstorage. because checking if running in browser will be difficult.

GillesC commented 8 years ago

cordova provides a cordova.platformId parameter whichs results in 'browser' when running in a browser.

alokrajiv commented 8 years ago

ok then. But, I thought that was for the 'browser' platform only. Anyways, try it. You can see this open issue link. Because usually in the browser cordova is undefined.

GillesC commented 8 years ago

Thank you, I was just checking the platformID, now I will check for cordova and phonegap also ;)

GillesC commented 8 years ago

Testing in browser is now possible. Would you check if your problem has been resolved?

Please remove the old version first:

cordova plugin remove cordova-plugin-nativestorage

And use the development version of the plugin:

cordova plugin add https://github.com/GillesC/cordova-plugin-nativestorage.git

Added browser for testing purposes in commit 29b4bb6348732b6b7ca260894f15eaf592e5d0a4.

alokrajiv commented 8 years ago

@GillesC are you able to reproduce the results on browser?

GillesC commented 8 years ago

Yup I've tested it through the browser platform.

alokrajiv commented 8 years ago

Working perfectly. I am closing the issue.

alokrajiv commented 8 years ago

commit 29b4bb6348732b6b7ca260894f15eaf592e5d0a4.

GillesC commented 8 years ago

Yeah, I thought waiting for @HbIXA to respond. And if his issue had been resolved, than to close this issue.

alokrajiv commented 8 years ago

Ok, lets wait for @HbIXA to confirm. If he doesnt soon, I'll reopen the issue.

alokrajiv commented 8 years ago

Temporarily reopening the issue for 48hrs. @HbIXA pls confirm that your issue is resolved. If not in 48hrs we'll close the issue because we have tested and aren't facing the issue anymore.

HbIXA commented 8 years ago
  1. rm plugin
  2. add plugin

result : plugin ls cordova-plugin-nativestorage 1.0.9 "NativeStorage"

version not updated

alokrajiv commented 8 years ago

cordova plugin remove cordova-plugin-nativestorage && cordova plugin add https://github.com/GillesC/cordova-plugin-nativestorage.git && cordova plugin ls

I suspect you didn't install the development version. Bcoz the v1.0.10 isn't on release yet.

GillesC commented 8 years ago

Like I said in a previous comment, you must install the development version. This because I'm waiting for your response to republish the plugin on npm.

The previous post: Testing in browser is now possible. Would you check if your problem has been resolved?

Please remove the old version first:

cordova plugin remove cordova-plugin-nativestorage

And use the development version of the plugin:

cordova plugin add https://github.com/GillesC/cordova-plugin-nativestorage.git
HbIXA commented 8 years ago

good job

GillesC commented 8 years ago

I think by 'good job' you meant, that the plugin works ;) I'll close this issue now.

Added browser for testing purposes in commit 29b4bb6.

jayj commented 8 years ago

Thanks for this. I have an issue where the inBrowser function returns true for me on Android because window.phonegap is undefined.

alokrajiv commented 8 years ago

@jayj I understood. But, let me recreate the issue. and I will respond back.

alokrajiv commented 8 years ago

@jayj Thank you for pointing the error , the commit actually broke the functionality. I am re-opening the issue while I update the inBrowser function.

alokrajiv commented 8 years ago

I have updated it. Please reinstall the development version and check. cordova plugin remove cordova-plugin-nativestorage && cordova plugin add https://github.com/GillesC/cordova-plugin-nativestorage.git And retry your use case. I beleive I have corrected the problem with commit 3714c9b319b650d70211af8e5fb7d26c314b9685. @jayj Please confirm.

jayj commented 8 years ago

@alokrajiv thanks for the quick fix! It works now 👍

GillesC commented 8 years ago

Glad thinks worked out! I'm re-closing the issue Problem corrected with commit 3714c9b

Updating the plugin on npm as well and version control on Github