【问题标题】:How to use Meteor-PhoneGap Plugin如何使用 Meteor-PhoneGap 插件
【发布时间】:2014-12-01 11:01:41
【问题描述】:

我开始使用 PhoneGap 与 Meteor 的集成,但无法让插件正常工作。有人可以提供以下我将如何使用相机插件的步骤。目前我只在模拟器上运行它。代码如下。提前致谢。

我添加了这样的相机插件: 流星添加cordova:org.apache.cordova.camera@0.3.1

然后使用它我有以下代码:

if (Meteor.isClient) {

  Template.hello.events({
    'click button': function () {
      // increment the counter when button is clicked
      navigator.camera.getPicture(
        function(data){ Session.set("picture", res); },

        function(err){ console.log(err); },

        {
          quality: 50,
          destinationType: Camera.DestinationType.DATA_URL
        }
      );
    }
  });
}

if (Meteor.isServer) {
  Meteor.startup(function () {
    // code to run on server at startup
  });
}

当我点击按钮时出现此错误:

I20141006-21:58:33.174(-7)? (ios) Camera.getPicture: source type 1 not available.
I20141006-21:58:33.222(-7)? (ios) no camera available

【问题讨论】:

  • 我不相信 iPhone 模拟器允许 GPS 或照片。我发现 Chrome 将允许您同时执行这两项操作。
  • @CodeChimp 此代码在 Android 模拟器上启动相机,但在浏览器上不起作用。有什么想法吗?
  • 查看我几周前的问题:stackoverflow.com/questions/26182267/…

标签: cordova meteor phonegap-plugins cordova-plugins


【解决方案1】:

根据 Meteor-Cordova-Phonegap 集成文档,

任何依赖于 Cordova/Phonegap 插件的功能都应该 将代码包装在 Meteor.startup() 块中

文档link here

【讨论】:

    猜你喜欢
    • 2014-12-18
    • 2015-08-01
    • 1970-01-01
    • 2013-03-13
    • 2016-06-14
    • 2016-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多