0

我想使用该$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,即使它在成功时不显示警报功能或在失败时不显示失败功能,它也会打开一个加载了 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 插件工作正常,但看起来每个插件都获得了call to unknown plugin.

4

1 回答 1

0

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

于 2015-07-06T22:09:36.207 回答