首页 > 解决方案 > 从科尔多瓦的 playstore 获取应用程序版本

问题描述

我正在尝试将应用程序的应用程序版本上传到 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版本的方法吗?

标签: androidajaxcordovasecurityhttps

解决方案


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

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

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

你已经安装了cordova-plugin-whitelist吗?


推荐阅读