cordova.file.* (all directories) are null

前端 未结 2 789
太阳男子
太阳男子 2021-01-19 18:57

I\'m working on Ionic mobile app development.

My requirement is to create client side logger to track issues in app. I used the methods mentioned in https://github.c

相关标签:
2条回答
  • 2021-01-19 19:07

    There is a check list here and should solve your problem :

    1-Be sure that the cordova-file-plugin is installed and works in your test environment.

    2-Be sure that the cordova.js file is refrenced by your html and before your code usage.

    3-Be sure to call your codes after device_ready state : check this

    4-Call your function after a short delay (use setTimeOut in Javascirpt)

    0 讨论(0)
  • 2021-01-19 19:30

    Ali's item 4 is very important: I had a similiar problem on different platforms: cordova.file.dataDirectory was null. I tracked cordova.file.dataDirectory over the lifecycle and it was first accessed by my Ionic 2 code BEFORE the device ready event was fired. My "mistake": I wanted to load data during the constructor(!) of a service. Seems too early.

    0 讨论(0)
提交回复
热议问题