Firebase Authentication does not Persist on Cordova iOS [Ionic/Cordova]

136 views
Skip to first unread message

Wolfgang Teves

unread,
Jul 11, 2018, 10:39:41 PM7/11/18
to Firebase Google Group
Hey there,

I'm having an Issue on iOS Devices where the available device storage is low.

When the user is Logging in, using Firebase Auth, it works successfully. But when he leaves the app, then some time passes, and opens the app again the session is lost. This can happen multiple times a day.

I think the root cause is, that iOS is deleting the Caches Folder when the available device storage is low:
<Application_Home>/Library/Caches directory

My Ionic Cordova Application uses the Web SDK of Firebase so the Data is saved in IndexedDb in the WebView which is put into the Caches folder.

A Typical solution for this would be to save it with a Cordova Plugin into SQLite.
When running in a native app context, Storage will prioritize using SQLite, as it's one of the most stable and widely used file-based databases, and avoids some of the pitfalls of things like localstorage and IndexedDB, such as the OS deciding to clear out such data in low disk-space situations.


My Problem now is, that i don't have control over where the Firebase Web SDK is saving the data. 

So I'm thinking about the following alternatives:

Getting hold of the User Token and save it in SQLite (preferred way)
-> I can get hold of the refreshToken, but apparently there is no way to log in with it other than implementing my own Login Mechanism 

Backing Up IndexedDb
-> I thought about "backing up" the data in IndexedDb when the user has logged in, and restoring it on App start up when necessary, but that is not as easy as it was with localstorage. 
(Seems like that was the solution here)

Found a library which can handle that but it seems a bit spooky to rely on that: https://github.com/Polarisation/indexeddb-export-import

Overwriting the window API of IndexedDb to write into SQLite:
-> Seems like a massive Task

So i'm wondering what i can do at this point.

I would be thankful for any suggestions!
Reply all
Reply to author
Forward
0 new messages