Cordova inAppBrowser只是拒绝在Android上工作

时间:2018-11-23 07:50:28

标签: android cordova cordova-plugins inappbrowser

最近,我再次开始与cordova合作,而且情况一直很糟糕。我正在尝试构建一个仅显示网页以及推送通知支持的移动应用程序。问题是,当我为Android构建时,即使插件加载正常,inAppBrowser也不起作用。它停留在初始屏幕中。另外,如果我从phoneGap Build进行构建,则可以正常工作(但它与我拥有的推插件不兼容,因此无法使用)。另外,如果我在浏览器上运行应用程序,该插件也可以正常工作。

我尝试过的事情:

  • 删除android平台并重建
  • 在新的干净cordova项目中复制整个www文件夹
  • 调试inAppBrowser

什么都没有。

这是我的config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.gr.---" version="1.0.0" xmlns="http://www.w3.org/ns/widgets"         xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>----</name>
<description>
    A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
    Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<allow-navigation href="*" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
    <allow-intent href="market:*" />
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
</platform>
<plugin name="cordova-plugin-device" spec="^2.0.2" />
<plugin name="cordova-plugin-inappbrowser" spec="^3.0.0" />
<plugin name="cordova-plugin-fcm-with-dependecy-updated" spec="^2.2.6" />
    <engine name="android" spec="^7.1.3" />
    <engine name="browser" spec="^5.0.4" />
</widget>

这是我的索引js文件:

class Messenger {
    constructor(uuid) {
        //TODO: Add firebase message events
        this.uuid = uuid ? uuid : "TESTING4";
        this.endpoint = "http://192.168.1.200/";

    }

    updateSettings() {

    }
}

var app = {
    initialize: function() {
        document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
    },

    onDeviceReady: function() {
        let messenger = new Messenger(device.uuid);
        let ref = cordova.InAppBrowser.open(messenger.endpoint + "register?uuid=" + messenger.uuid, '_blank',"location=no");
    },
};

app.initialize();

这是我的索引html文件:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' ws: data: gap: https://ssl.gstatic.com 'unsafe-eval'; frame-src *;script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>FXTipster</title>
    </head>
    <body class="bg-fx">
        <div class="app">
            <div class="main-image-container">
                <img src="img/logo.png" class="main-image">
            </div>
            <div class="loader-container">
                <div class="loader"></div>
            </div>
        </div>


        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="cordova_plugins.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
    </body>
</html>

0 个答案:

没有答案