我想用 $cordovaInAppBrowser
插件在我的应用程序中打开一个YouTube窗口。
我正在使用ngCordova与Ionic。我尝试了这种方式。
$scope.youtube = function () {
var options = {
location: 'yes',
clearcache: 'yes',
toolbar: 'no'
};
alert('option set');
$cordovaInAppBrowser.open('http://www.youtube.fr', '_blank', options)
.then(function (event) {
alert('success');
})
.catch(function (event) {
alert('fail');
});
}
在Chrome浏览器中,当我做一个 ionic serve android
但在安卓系统上却完全不行,什么都没有发生,而且我在控制台中也没有得到任何错误信息。我不能在iPhone上测试它,因为我没有iPhone.有人知道为什么它的行为方式吗?
好的,这是一块安卓系统的日志跟踪,在为安卓系统构建之后。
07-06 16:31:04.870 19469-19515/me.app.id I/App﹕ WARNING: Back Button Default Behavior will be overridden. The backbutton event will be fired!
07-06 16:31:14.540 19469-19469/me.app.id D/SystemWebChromeClient﹕ file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js: Line 173 : No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.
07-06 16:31:14.540 19469-19469/me.app.id I/chromium﹕ [INFO:CONSOLE(173)] "No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.", source: file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js (173)
07-06 16:31:14.540 19469-19515/me.app.id D/PluginManager﹕ exec() call to unknown plugin: Console
07-06 16:31:24.530 19469-19469/me.app.id D/SystemWebChromeClient﹕ file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js: Line 173 : No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.
07-06 16:31:24.530 19469-19469/me.app.id I/chromium﹕ [INFO:CONSOLE(173)] "No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.", source: file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js (173)
07-06 16:31:24.540 19469-19515/me.app.id D/PluginManager﹕ exec() call to unknown plugin: Console
07-06 16:31:24.870 19469-19469/me.app.id D/dalvikvm﹕ GC_FOR_ALLOC freed 593K, 10% free 12440K/13676K, paused 13ms, total 15ms
07-06 16:31:24.880 19469-19469/me.app.id I/dalvikvm-heap﹕ Grow heap (frag case) to 15.263MB for 1127536-byte allocation
07-06 16:31:25.870 19469-19515/me.app.id D/PluginManager﹕ exec() call to unknown plugin: InAppBrowser
看起来插件没有被调用。但我检查了两次,我是用好的方式调用它的。
var app = angular.module('starter', ['ionic', 'azure-mobile-service.module', 'ngCordova']);
而在控制器中。
app.controller('PosterCtrl', ['$scope', '$location', 'Azureservice', '$localstorage', '$ionicLoading', '$cordovaCamera', '$cordovaFile', '$cordovaInAppBrowser',
function ($scope, $location, Azureservice, $localstorage, $ionicLoading, $cordovaCamera, $cordovaFile, $cordovaInAppBrowser)
其他的ngCordova插件工作正常,但看起来每个插件都得到了 call to unknown plugin
.
算了,我的错,我只是把版本搞乱了...。azure-mobile-services插件需要org.apache.cordova.inappbrowser,所以它没有安装好最新版本。我只是删除了所有的东西,并添加了我的插件的良好秩序。谢谢你