【问题标题】:cordova-plugin-camera installed but xcode saying plugin is not installed已安装cordova-plugin-camera,但未安装xcode说插件
【发布时间】:2019-05-14 22:18:28
【问题描述】:

我正在尝试让 cordova-plugin-camera 处理我的 Ionic 应用程序。我使用cordova plugin add cordova-plugin-camera --save 安装它,然后使用npm i --save @ionic-native/camera。该包的 node_modules 文件夹已填充,并且该插件存在于我的所有插件文件夹中,我还验证了 cordova plugin list 显示该插件。我正在使用以下代码尝试启动相机,但它不工作:

import { Component } from "@angular/core";
import { Platform } from "ionic-angular";
import { Camera, CameraOptions } from "@ionic-native/camera";

@Component({
  selector: "page-camera",
  templateUrl: "camera.html"
})
export class CameraPage {
  public base64Image: string;

  constructor(public camera: Camera, public platform: Platform) {}

  takePicture() {
    this.platform.ready().then(() => {
      this.camera
        .getPicture({
          destinationType: this.camera.DestinationType.DATA_URL,
          targetWidth: 1000,
          targetHeight: 1000
        })
        .then(
          imageData => {
            // imageData is a base64 encoded string
            this.base64Image = "data:image/jpeg;base64," + imageData;
          },
          err => {
            console.log(err);
          }
        );
    });
  }
}

运行此程序并单击调用 takePicture() 的按钮时,我没有启动相机,也没有控制台错误,但在 safari 内部我收到以下错误:

2018-12-13 11:31:24.183490-0500 MyApp[3844:312133] ERROR: Plugin 'Camera' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2018-12-13 11:31:24.183546-0500 MyApp[3844:312133] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["Camera1764610053","Camera","takePicture",[50,0,1,1000,1000,0,0,false,false,false,null,0]]

【问题讨论】:

  • 你是如何以及在哪里运行这个的?相机插件是否支持这个平台?
  • @janpio 我有一个单独的相机页面。绝对支持我的 iPhone 平台。
  • 您没有在描述中明确提到您在 iOS 上运行。 Cordova 插件仅在deviceready 之后可用,也许ionicframework.com/docs/api/platform/Platform/#ready 会解决您的问题。
  • @janpio 这并不能解决我的问题。我应该可以通过一个函数来启动它。
  • @janpio 我已将我的代码更新为与platform.ready() 一起使用的代码。它仍然抛出完全相同的错误。

标签: ios cordova ionic-framework camera cordova-plugins


【解决方案1】:

重置我的分支并重新安装,成功了。我不确定发生了什么,但认为它只是安装不正确。

【讨论】:

    猜你喜欢
    • 2018-04-05
    • 2021-04-11
    • 2015-12-06
    • 2018-03-02
    • 2012-01-05
    • 2017-10-22
    • 1970-01-01
    • 1970-01-01
    • 2021-07-14
    相关资源
    最近更新 更多