2014-10-07 69 views
0

我开始使用与Meteor的PhoneGap集成,并且无法让插件工作。有人可能会提供以下步骤,我将如何使用相机插件。目前我只在模拟器上运行它。代码如下。预先感谢。如何使用流星PhoneGap插件

我加入了摄像头插件是这样的: 流星添加科尔多瓦:[email protected]

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

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 
+0

我不相信iPhone模拟器允许GPS或照片。 Chrome会让你做到这一点,我发现。 – CodeChimp 2014-10-07 19:59:27

+0

@CodeChimp此代码在Android模拟器上启动相机,但不适用于浏览器。有什么想法吗? – 2014-10-15 03:34:53

+0

几周前看到我的问题:http://stackoverflow.com/questions/26182267/error-while-taking-pictures-using-meteorcamera-getpicture-while-testing-on-a-l – CodeChimp 2014-10-15 10:31:24

回答

0

根据流星 - 科尔多瓦 - PhoneGap的集成文档,

Any functionality which relies on a Cordova/Phonegap plugin should wrap code in a Meteor.startup() block

文档link here