Ionic Storage is not working on Android device

梦想的初衷 提交于 2020-01-06 07:15:08

问题


I'm new to the Ionic Framework, and I'm doing an app that preserves the user login so it can show a different page when user is logged. And for doing this, I'm saving the user ID into the local storage. This works fine when I do ionic serve and testing the code on browser, but it doesn't work on my Android device (so I run ionic cordova run android). Why? I have set the Storage right by using IonicStorageModule.forRoot() in app.module.ts -> imports[...]. Here's my code and my Ionic specs:


回答1:


I just figured out my problem and built a solution. On the very first access in my app userLoggedID is completely empty (it wasn't neither undefined nor null), so I attached a catch() instruction and now the code works fine.

LOG:



来源:https://stackoverflow.com/questions/54028978/ionic-storage-is-not-working-on-android-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!