ionic-team / ionic-v3

The repo for Ionic 3.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
Other
128 stars 85 forks source link

DOMException: Requested device not found - get picture in ionic 3 #806

Open ionitron-bot[bot] opened 5 years ago

ionitron-bot[bot] commented 5 years ago

Original issue by @jamshidyarkamran on 2018-09-14T12:21:21Z

I use this ionic3. i need to take picture in ionic browser. An error occurs. Please help me with a solution.

error in chrome : DOMException: Requested device not found

error in firefox :

MediaStreamError __zone_symbol__currentTask: null constraint: "" message: "The object can not be found here." name: "NotFoundError" stack: ""

my codes :

const options: CameraOptions = {
      quality: 100,
      destinationType: this.platform.is('ios') ? this.camera.DestinationType.FILE_URI : this.camera.DestinationType.DATA_URL,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE,
      saveToPhotoAlbum: false
    };
    this.camera.getPicture(options).then((imageData) => {
      let base64Image = null;
      if (this.platform.is('ios')) {
        base64Image = normalizeURL(imageData);
      }
      else {
        base64Image = "data:image/jpeg;base64," + imageData;
      }
      console.log(base64Image);
    }, (error) => {
      console.log(error); // error : DOMException: Requested device not found
    });
  }

package.json :


{
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "^5.2.11",
    "@angular/core": "^5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "^5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/camera": "^4.12.2",
    "@ionic-native/core": "^4.12.2",
    "@ionic-native/geolocation": "^4.12.2",
    "@ionic-native/network": "^4.12.2",
    "@ionic-native/splash-screen": "^4.12.2",
    "@ionic-native/status-bar": "^4.12.2",
    "@ionic/storage": "^2.1.3",
    "cordova-android": "7.0.0",
    "cordova-browser": "5.0.3",
    "cordova-plugin-camera": "^4.0.3",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-geolocation": "^4.0.1",
    "cordova-plugin-ionic-keyboard": "^2.1.2",
    "cordova-plugin-ionic-webview": "^2.1.4",
    "cordova-plugin-network-information": "^2.0.1",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-sqlite-storage": "^2.4.0",
    "ionic-angular": "3.9.2",
    "ionic-native": "^2.9.0",
    "ionicons": "3.0.0",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "web-animations-js": "^2.3.1",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.11",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-ionic-keyboard": {},
      "mx.ferreyra.callnumber": {},
      "cordova-sqlite-storage": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
      },
      "phonegap-plugin-barcodescanner": {},
      "call-number": {},
      "cordova-plugin-camera": {
        "CAMERA_USAGE_DESCRIPTION": "cud",
        "PHOTOLIBRARY_USAGE_DESCRIPTION": "pud"
      },
      "cordova-plugin-device": {},
      "cordova-plugin-statusbar": {}
    },
    "platforms": [
      "android",
      "browser"
    ]
  }
}
iliyaZelenko commented 5 years ago

I have the same problem in the browser (https://github.com/ionic-team/ionic-native/issues/2855), but I am using version @ionic/angular 4.0.0-rc.0.

scottieslg commented 5 years ago

I am occasionally getting this error as well. Any advice on how to fix this?