Gabe O'Leary
Gabe O'Leary

Reputation: 2070

How can I access my app's ionic-storage (localForage) from a second web view?

I have an ionic app that uses ionic-storage. I also have a native android background service that generates a separate webview to do work outside of the ionic app. This service needs to write to the app's storage. I am using the same config (name & storeName) for both of these storage objects but they seem to be accessing completely different spaces, I'm guessing because they are separate WebViews.

Has anyone else encountered a similar problem or know how I might be able to remedy this?

Upvotes: 0

Views: 860

Answers (1)

Gabe O'Leary
Gabe O'Leary

Reputation: 2070

The issue was that Ionic instantiates the storage object with a different priority for storage drivers than if you just do let storage = new Storage(); (what I'm doing in my separate background service WebView). I was unable to get my non-ionic WebView to use SQLite correctly so I just changed the driver order for my ionic app using driverOrder: ['indexeddb', 'sqlite', 'websql'].

This resulted in both the Ionic App and and the extra WebView accessing the same storage area.

Upvotes: 2

Related Questions