You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Chris,
Thanks for these mocks. I'm hoping I can get them functioning. We're on a really tight timeline.
I've implemented the mocks via npm and I just added some logic that uses File and FileTranfer plugins.
NOTE: This app should also be able to run in the browser when it goes public. Am I missing something there? We have another Cordova app that uses plugins and I don't see these issues in the browser. i.e. also using the File and FileTransfer plugins.
The problem I'm facing is that I still receive warnings in the chrome console after implementing the mocks: Ionic Native: tried calling File.dataDirectory, but Cordova is not available. Make sure to a) run in a real device or simulator and b) include cordova.js in your index.html.
AND
Native: tried accessing the FileTransfer plugin but Cordova is not available. Make sure to a) run in a real device or simulator and b) include cordova.js in your index.html
Here is my app.module.ts:
import { File } from '@ionic-native/file';
import { FileMock } from '@ionic-native-mocks/file';
import { FileTransfer } from '@ionic-native/file-transfer';
import { FileTransferMock } from '@ionic-native-mocks/file-transfer';
...
providers: [
...
//// USE MOCK FOR CORDOVA PROVIDERS IF IN BROWSER
//File,
//FileTransfer,
(isBrowser ? { provide: File, useClass: FileMock } : File),
(isBrowser ? { provide: FileTransfer, useClass: FileTransferMock } : FileTransfer),
...
Next, I wrote my own provider (wrapper) for file related functions file-utils.ts:
...
import { File } from '@ionic-native/file'; << Seemed unusual that this doesn't import the MOCK?!
import { FileTransfer } from '@ionic-native/file-transfer'; << Seemed unusual that this doesn't import the MOCK?!
...
constructor(public http: HttpClient, public platform: Platform, public storage: Storage, public globals: Globals, public file: File, public transfer: FileTransfer, public zip: Zip) {
console.log('Construct FileUtils Provider');
//Determine device storage folder per OS
//if (this.platform.is('android'))
// globals.deviceStorageFolder = this.file.dataDirectory;
//else globals.deviceStorageFolder = this.file.documentsDirectory; globals.deviceStorageFolder = this.file.dataDirectory;
console.log('Got File.dataDirectory = ' + globals.deviceStorageFolder);
}
...
So the question is, is the npm implementation enough in my case, or do I need to customize the file.dataDirectory? What would I return? Would be something like C:\Temp?
What about FileTransfer which is not available at all even with the mocks in place?
The text was updated successfully, but these errors were encountered:
Ionic v4 actually.
In the meantime, I've resorted to: ionic cordova run browser
But of course, I no longer benefit from livereload and debugging features of VS Code
Chris,
Thanks for these mocks. I'm hoping I can get them functioning. We're on a really tight timeline.
I've implemented the mocks via npm and I just added some logic that uses File and FileTranfer plugins.
NOTE: This app should also be able to run in the browser when it goes public. Am I missing something there? We have another Cordova app that uses plugins and I don't see these issues in the browser. i.e. also using the File and FileTransfer plugins.
The problem I'm facing is that I still receive warnings in the chrome console after implementing the mocks:
Ionic Native: tried calling File.dataDirectory, but Cordova is not available. Make sure to a) run in a real device or simulator and b) include cordova.js in your index.html.
AND
Native: tried accessing the FileTransfer plugin but Cordova is not available. Make sure to a) run in a real device or simulator and b) include cordova.js in your index.html
Here is my app.module.ts:
import { File } from '@ionic-native/file';
import { FileMock } from '@ionic-native-mocks/file';
import { FileTransfer } from '@ionic-native/file-transfer';
import { FileTransferMock } from '@ionic-native-mocks/file-transfer';
...
providers: [
...
//// USE MOCK FOR CORDOVA PROVIDERS IF IN BROWSER
//File,
//FileTransfer,
(isBrowser ? { provide: File, useClass: FileMock } : File),
(isBrowser ? { provide: FileTransfer, useClass: FileTransferMock } : FileTransfer),
...
Next, I wrote my own provider (wrapper) for file related functions file-utils.ts:
...
import { File } from '@ionic-native/file'; << Seemed unusual that this doesn't import the MOCK?!
import { FileTransfer } from '@ionic-native/file-transfer'; << Seemed unusual that this doesn't import the MOCK?!
...
constructor(public http: HttpClient, public platform: Platform, public storage: Storage, public globals: Globals, public file: File, public transfer: FileTransfer, public zip: Zip) {
console.log('Construct FileUtils Provider');
//Determine device storage folder per OS
//if (this.platform.is('android'))
// globals.deviceStorageFolder = this.file.dataDirectory;
//else globals.deviceStorageFolder = this.file.documentsDirectory;
globals.deviceStorageFolder = this.file.dataDirectory;
console.log('Got File.dataDirectory = ' + globals.deviceStorageFolder);
}
...
So the question is, is the npm implementation enough in my case, or do I need to customize the file.dataDirectory? What would I return? Would be something like C:\Temp?
What about FileTransfer which is not available at all even with the mocks in place?
The text was updated successfully, but these errors were encountered: