$ cordovaInAppBrowser没有使用ngCordova和Ionic

时间:2015-07-06 12:58:40

标签: angularjs cordova ionic inappbrowser ngcordova

我想使用$ cordovaInAppBrowser插件在我的应用中打开youtube窗口。 我使用ngCordova和离子。我试过这种方式:

$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');
      });

}

当我执行" ionic serve android"时,这在Chrome浏览器中完美运行,即使它在失败时成功或失败功能时也不显示警报功能,它会打开一个新的用youtube加载的页面。 但这在android上根本不起作用,没有任何反应,我在控制台中没有收到任何错误消息。我无法在Iphone上测试它,因为我没有。 有人知道为什么它会这样做吗?

好的,这是为android安装后的一段android日志跟踪:

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插件工作正常,但看起来每个插件都会调用未知插件"

1 个答案:

答案 0 :(得分:0)

没关系,我的坏,我只是搞乱了版本.... azure-mobile-services插件需要org.apache.cordova.inappbrowser,所以它没有安装好最新版本。我刚刚删除了所有内容并按顺序添加了我的插件。谢谢!