Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cordova.file is undefined for windows / wp8

I'm trying to export an app done with Cordova to desktop/tablet Windows 8.1 and Windows Phone 8.1. My app works successfully on Android, iOS.

cordova -v
4.1.2

cordova plugins list
org.apache.cordova.file 1.3.1 "File"

But when I try on a Windows 8.1 or Windows Phone my app fails. The "cordova.file" is undefined. I can't access to cordova.file.dataDirectory to store my data or any cordova.file.* properties alias.

I see no "Quirks" for Windows on https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md, did I miss something ?

UPDATE

Found a solution for Windows Phone, I set the 'cordova.file.dataDirectory' to '///' (device require org.apache.cordova.device) :

if(cordova.file === undefined){
    // WP8
    if(device.platform === "Win32NT"){
        cordova.file = {
            dataDirectory: '///'
        }
    }else
    // Windows 8
    if(device.platform === "windows"){
        cordova.file = {
            dataDirectory: '?????'
        }
    }
}

For Windows 8 I still seek for a solution..

like image 330
cub Avatar asked Sep 29 '22 10:09

cub


1 Answers

'ms-appdata:///local/' works for Windows 8 and WP 8.1

https://msdn.microsoft.com/en-us/library/windows/apps/jj655406.aspx has info on other available data paths

like image 51
nfkb Avatar answered Oct 03 '22 00:10

nfkb