ewizard ewizard -4 years ago 149
TypeScript Question

Ionic 2 - (window as any).resolveLocalFileSystemURL() throwing error

I have some typescript code that uses the camera:

this.camera.getPicture(this.optionsGetCamera).then((imageURI) => {
if (this.platform.is('ios')) {
this.crop.crop(imageURI, { quality: 100 }).then(newPath => {
(window as any).resolveLocalFileSystemURL(newPath, function (fileEntry) {
}).catch((error) => { ...

When I run the app, and use the camera function that gets used in this code, I get an error in the console (I am running on a device using the -lc parameter to view the log):

console.error: ERROR ->

line 58535
is this:

window.resolveLocalFileSystemURL(newPath, function (fileEntry) {

This line is in the main.js file that gets created by ionic on build. I have been trying to understand
as it seems like it might point to the problem (with a promise? or not using one?). Thanks.

Answer Source

use the File class from ionic native means The Typescript class don't use the javascript any type refer https://ionicframework.com/docs/native/file/

import {Component} from '@angular/core';
import {File} from 'ionic-native';


  (files) => {
    // do something
  (err) => {
    // do something
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download