1.先添加mobile平台
2.search cordova plugin in Plugin Search - Apache Cordova
3.添加插件
meteor add cordova:插件名@版本号
或者
package.js中添加
Cordova.depends({
'cordova-plugin-camera':'1.2.0'
});
指定git下载
meteor add cordova:com.phonegap.plugins.facebookconnect@https://github.com/Wizcorp/phonegap-facebook-plugin.git#5dbb1583168558b4447a13235283803151cb04ec
Cordova.depends({
'com.phonegap.plugins.facebookconnect':'https://github.com/Wizcorp/phonegap-facebook-plugin.git#5dbb1583168558b4447a13235283803151cb04ec'
});
从本地应用
meteor add cordova:cordova-plugin-underdevelopment@file://../plugins/cordova-plugin-underdevelopment
Cordova.depends({
'cordova-plugin-underdevelopment':'file://../plugins/cordova-plugin-underdevelopment'
});
4使用:
所有依赖cordova的代码都要放在
Meteor.startup()代码块中
// The plugin may not have been initialized here
navigator.geolocation.getCurrentPosition(success);
Meteor.startup(function(){
// Here we can be sure the plugin has been initialized
navigator.geolocation.getCurrentPosition(success);
});
区分server,client,cordova
if(Meteor.isServer) {
console.log("Printed on the server");
}
if(Meteor.isClient) {
console.log("Printed in browsers and mobile apps");
}
if(Meteor.isCordova) {
console.log("Printed only in mobile Cordova apps");
}
package.js中可以定义资源文件在那里使用
api.addFiles('foo.js', 'web.cordova'): includesfoo.jsin only Cordova builds.
api.addFiles('bar.js', 'web.browser'): includesbar.jsin only browser builds.
api.addFiles('baz.js', 'web'): includesbaz.jsin all client builds.
访问资源路径
并非使用file:// URL而是使用的http://localhost:/local-filesystem/或者使用WebAppLocalServer.localFileSystemUrl()转换 file://URLs.
访问白名单
App.accessRule方法在mobile-config.js设置权限 (config.xml文件中的access, allow-navigation, allow-intent标签)
App.accessRule('https://domain.com', {
'minimum-tls-version':'TLSv1.0',
'requires-forward-secrecy':false,
});
更多配置继续阅读参考
参考:Mobile
cordova-plugin-googleplus
scopes:
developers.google.com/android/reference/com/google/android/gms/common/Scopes.html#DRIVE_FILE
console.developers.google.com/apis/credentials 申请webclientid
developers.google.com/mobile/add 启动google app服务配置sh1,packagename
cordova-plugin-wechat
网友评论