问题描述
我是新来的流星。我正在开发与流星的移动应用程序。我需要添加<获得原产地=*/>在浏览器
config.xml中我使用谷歌API工作正常。但是,当我在Android设备上运行,控制台会抛出未捕获的ReferenceError:谷歌没有定义
。我认为这个问题是科尔多瓦块谷歌的API。我应该如何从流星添加访问来源?
I am new to meteor. I am developing mobile app with meteor. I need to add <access origin="*"/>
in config.xml I am using google API works fine in browser. But when I run in android device, console throws Uncaught ReferenceError: google is not defined
. I think the problem is cordova blocks google api. How should I add access origin from meteor?
推荐答案
创建您的根流星项目移动config.js文件。读https://docs.meteor.com/#/full/mobileconfigjs
Create a mobile-config.js file in your root meteor project. Read https://docs.meteor.com/#/full/mobileconfigjs
您可以添加一个原点通配符,像这样。
You can add an origin wildcard like so.
App.accessRule('*');
这将以下内容添加到您的config.xml
This will add the following to your config.xml
<access origin="*"/>
下面是:https://docs.meteor.com/#/full/App-accessRule
App.accessRule(domainRule,[选项])
设置根据您的应用程序的原始域,新的访问规则。默认 您的应用程序服务器,它可以接触的有限清单。使用 这种方法来扩展此列表。
Set a new access rule based on origin domain for your app. By default your application has a limited list of servers it can contact. Use this method to extend this list.
默认访问规则:
- 电话:,GEO:的,邮寄地址:,短信:的,市场:*允许并启动外部(手机应用程序,或在Android上的电子邮件客户端)
- 差距:,CDV:的,文件:允许(需要协议来访问本地文件系统) HTTP://流星。本地/ *允许(域流星使用
访问应用程序的资产) - 传递到构建过程(或开发模式下的本地IP地址)的服务器的域用于能够联系的
流星的应用服务器。
- tel:, geo:, mailto:, sms:, market:* are allowed and launch externally (phone app, or an email client on Android)
- gap:, cdv:, file: are allowed (protocols required to access local file-system) http://meteor.local/* is allowed (a domain Meteor uses
to access app's assets) - The domain of the server passed to the build process (or local ip address in the development mode) is used to be able to contact the
Meteor app server.
了解更多关于域模式科尔多瓦文档。
与所有域和协议流星1.0.4访问规则开始 ()不再默认设置,由于一定 一种可能的攻击。
Starting with Meteor 1.0.4 access rule for all domains and protocols () is no longer set by default due to certain kind of possible attacks.
参数的
domainRule 字符串 - 确定受影响的域名或网址的模式
domainRule String - The pattern defining affected domains or URLs.
选项的
launchExternal 布尔 - 设置为true,如果匹配的URL应该在外部处理(如手机应用程序或Android上的电子邮件客户端)
launchExternal Boolean - Set to true if the matching URL should be handled externally (e.g. phone app or email client on Android).
这篇关于在流星的应用程序如何添加由来= *科尔多瓦config.xml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!