【问题标题】:Getting app version from playstore in cordova从科尔多瓦的 playstore 获取应用程序版本
【发布时间】:2021-10-07 16:11:43
【问题描述】:

我正在尝试将应用程序的应用程序版本上传到 Playstore,我正在尝试使用 https://play.google.com/store/apps/details?id 和此代码

var url = 'https://play.google.com/store/apps/details?id=' + appID;
           $.ajax({
                url: your_url,
                type: 'GET',
                crossDomain:true,
                success: function(res) {
                    let storeVersion =null;
                    var doc=null;
                    var tag=null;
                    var parser = new DOMParser(),
                    doc = parser.parseFromString(res, 'text/html');
                    if (doc) 
                    {
                        tag = doc.querySelectorAll(".hAyfc .htlgb");
                        if (tag && tag[6]) {
                            storeVersion = tag[6].innerText.trim();
                        }
                    }
            });

在模拟器中正常工作,但在物理设备中返回错误 403,我尝试在内容安全策略中添加很多选项

<meta http-equiv="Content-Security-Policy" content="default-src *; img-src * data: https: 'self' 'unsafe-inline' 'unsafe-eval' ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src *; connect-src * data: https: 'self' 'unsafe-inline' 'unsafe-eval' https://play.google.com">

但没有工作,我错过了什么吗?还有其他获取 playstore 版本的方法吗?

【问题讨论】:

    标签: android ajax cordova security https


    【解决方案1】:

    请检查config.xml 并确保这些行已添加。

    <allow-navigation href="*" />
    <access origin="*" />
    

    您使用的是什么版本的 Cordova 和 Cordova Android?

    您是否已经安装了cordova-plugin-whitelist

    【讨论】:

    • 嗨,我在 config.xml 中有这些行,我使用的是 cordova 8.1.2 和 cordova android 8.0.0 并且有 cordova 白名单 1.3.4
    猜你喜欢
    • 2015-12-18
    • 2017-01-11
    • 2017-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多