如何从远程页面访问phonegap API [英] How to get access to phonegap API from a remote page

查看:146
本文介绍了如何从远程页面访问phonegap API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下情况:
我有一个已经存在的远程网页,我想开发一个使用这个页面的应用程序。
到目前为止,这么好。当我启动应用程序时,本地 index.html 被加载,它重定向( window.open target:_self )外部网站。这个网站在phonegap网页视图中打开。在外部网站上,我添加了 cordova.js 以访问本机phonegap API。但是它不能正常工作。 deviceReady 事件已正确触发,但我无法访问phonegap API,例如navigator.camera。

I have to following situation: I have a already existing remote webpage and i want to develope an app which uses this page. So far, so good. When I start the app the local index.html is loaded and it redirects (window.open target: _self) to the external website. This website is opened in the phonegap webview. On the external website I added the cordova.js in order to get access to the native phonegap API. But it doesn't work correctly. The deviceReady event is triggered correctly, but I have no access to the phonegap API, for example navigator.camera.

如何获取完成,以访问API?

How can I get it done, to get access to the API?

请不要评论它将被AppStore等拒绝。

Please do not comment that it will be rejected by AppStore etc. etc.

感谢您的帮助!

推荐答案

我也遇到过这个问题, (内容和访问标签)没有工作。我检查了应用程序,当它在电话上运行,我发现,当我加载远程站点有一些文件丢失。

I've had this problem as well and changing things in config.xml(content and access tags) didn't work. I inspected the app while it was running on the phone and I discovered that when I loaded the remote site there were some files missing.

首先它的文件名为 cordova_plugins.js ,您可以在平台文件夹中找到每个平台。然后你还需要一些插件特定的文件。你可以通过做一个构建并从那里提取它们来找到这些。对于android的路径如下APK / assets / www / plugins。只是复制您的服务器上的内容,你很好去。

First off it's the file called cordova_plugins.js which you can find for each platform in the platform folder. Then you also need some plugin specific files. You can find these by doing a build and extracting them from there. For android the path is as follows APK/assets/www/plugins. Just copy the contents on your server and you're good to go.

注意:您还可以在平台文件夹中找到插件特定文件,但它们不完整,因为他们缺少cordova.define ...开始时,这会导致必需模块未定义,因此只需执行构建,然后从中获取。

NOTE: you can also find the plugin specific files in the platform folder, but they are incomplete as they're missing cordova.define("... at the beginning. This leads to required and module being undefined, so just do a build and get them from there.

这篇关于如何从远程页面访问phonegap API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆