javascript - 我如何将 Cordova 与 Meteor 和 React 一起使用?

标签 javascript cordova reactjs meteor

我很难将 Cordova 插件与 Meteor 和 React 一起使用,从我看到的文档中可以看出:

You should wrap any functionality which relies on a Cordova plugin in a Meteor.startup() block to make sure the plugin has been fully initialized (by listening to the deviceready event). For example, when using the Cordova geolocation plugin:

Meteor.startup(function() {
    // Here we can be sure the plugin has been initialized
    navigator.geolocation.getCurrentPosition(success); });
}

我知道我需要定义这个:

Cordova.depends({
    'org.apache.cordova.camera': '0.3.1'
});

但是我有一些问题:

1º - 我可以将此函数 Meteor.startup() 放在服务器内部和客户端内部的任何位置吗?

2º - 我需要将 Cordova.depends() 放在哪里?在 Meteor > local 上有 packages 文件,但不是 js 文件。

3º - 在定义了 Cordova.depends() 之后,我可以通过 React 从客户端调用函数吗?如果是,怎么做?

一些这样的例子会很棒!

最佳答案

经过一段时间的研究,我找到了答案:

1 - 我已经有了 Meteor.startup(),它在客户端文件夹内的 main.js 文件中。

2 - 根据 docs,我不需要放置 Cordova.depends() :

In contrast to Meteor packages, you’ll have to specify the exact version of the plugin. This can be a bit of a pain because you first need to look up what the most recent (compatible) version of a plugin is before you can add it.

3 - 我可以在客户端或服务器上调用 Cordova 插件的功能,但我需要只使用 native 应用程序来实现,我现在正在制作一个 web 应用程序,然后我不能那样做。但是在 Developing on device 之后,有一种方法可以用 Meteor 做到这一点。 session 。

关于javascript - 我如何将 Cordova 与 Meteor 和 React 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43376429/

相关文章:

javascript - 本地存储字体系列

android - Cordova PushPlugin 在 Android 模拟器上未收到通知

reactjs - 在使用 Headless UI "Listbox"(在内部管理自己的状态)的同时更新 Formik 状态

javascript - React + flux : can action return a value?(例如最后创建的 id)

javascript - 将 .NET Core 环境传递给 React.JS 应用程序

javascript - CreateJS 中的补间函数

javascript - 我的水平菜单被我自己的图像隐藏了

javascript - 将javascript添加到wordpress页面

android - 为在 Visual Studio 中开发的 Cordova App 签名 Apk

ios - iOS 音乐游戏的最佳低延迟音频 API? OpenAL、Cocoas2d Denshion、PhoneGap