cordova.file。*(所有目录)都为null [英] cordova.file.* (all directories) are null

查看:471
本文介绍了cordova.file。*(所有目录)都为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正致力于Ionic移动应用开发。

I'm working on Ionic mobile app development.

我的要求是创建客户端记录器以跟踪应用中的问题。我使用了 https://github.com/pbakondy/filelogger 中提到的方法,我能够在Android和iOS中创建日志文件。

My requirement is to create client side logger to track issues in app. I used the methods mentioned in https://github.com/pbakondy/filelogger, and I could able to create the log file in both Android and iOS.

第一次打开应用程序时,它会在cordova.file.dataDirectory中创建日志文件,当我关闭并重新打开i * OS中的应用程序,我正在尝试阅读使用以下内容创建的文件内容

For the first time when I open the app, it creates the log file in cordova.file.dataDirectory, when I close and reopen the app in i*OS, I'm trying to read the content of the file which was created using the below

$fileLogger.getLogfile().then(function (loggerContent) {
                    var temp =loggerContent;
                });

但应用程序说

{ 
"applicationDirectory":null,
"applicationStorageDirectory":null,
"dataDirectory":null,
"cacheDirectory":null,
"externalApplicationStorageDirectory":null,
"externalDataDirectory":null,
"externalCacheDirectory":null,
"externalRootDirectory":null,
"tempDirectory":null,
"syncedDataDirectory":null,
"documentsDirectory":null,
"sharedDirectory":null
}

所以我无法找到我保存日志的文件。

So I couldn't able to find the file where i saved my logs.

请帮我解决这个问题或者如果你可以推荐一个不同的方法来解决这个问题,那会很棒!

Please help me resolve this issue or if you could recommend me a different method to get around this issue, that would be great!

谢谢你的回答

推荐答案

这里有一个检查清单,可以解决您的问题:

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

1 - 确保cordova-file-plugin已安装并在您的测试环境中工作。

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

2 - 确保你的html和你的代码使用前你的cordova.js文件都被引用了。

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

3 - 确保在device_ready状态后调用您的代码:
check 这个

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

4 - 短暂延迟后调用你的函数(在Javascirpt中使用setTimeOut)

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

这篇关于cordova.file。*(所有目录)都为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆