首页 > 解决方案 > Cordova webintent 限制

问题描述

我在我的项目中使用 cordova webintent 进行内部更新。这适用于android 6。

我有这个在 android 9 中的新设备,当我尝试更新我的应用程序时,它显示 Failed to open android intent。

如果关于 android 版本有限制,我一直在网上搜索,cordova plugin webintent但我没有任何问题。

下面是我的代码下载并调用我的 apk 文件开始安装。这同样适用于 android 版本 6。

var fileURL = cordova.file.externalDataDirectory + 'lg.apk';
                    var fileTransfer = new FileTransfer();
                    var uri = encodeURI(API_URL+"debug.apk?v="+AppVersion.version);
                    var errorCodes = {
                        '1' : 'FileTransferError.FILE_NOT_FOUND_ERR',
                        '2' : 'FileTransferError.INVALID_URL_ERR',
                        '3' : 'FileTransferError.CONNECTION_ERR',
                        '4' : 'FileTransferError.ABORT_ERR',
                        '5' : 'FileTransferError.NOT_MODIFIED_ERR'
                    }
fileTransfer.download(
                        uri,
                        fileURL,
                        function (entry) {
                            //promptForUpdateAndroid(entry);
                            /** **/
                            $rootScope.updatingApp = false;
                            $rootScope.loading = false;
                            func.logout();
                            $rootScope.$apply();
                            window.plugins.webintent.startActivity({
                                action: window.plugins.webintent.ACTION_VIEW,
                                url: entry.toURL(),
                                type: 'application/vnd.android.package-archive'
                            },
                            function () {
                                $rootScope.updatingApp = false;
                                $rootScope.$apply();
                            },
                            function () {
                                $rootScope.updatingApp = false;
                                $rootScope.$apply();
                                alert('Failed to open URL via Android Intent.');
                                console.log(entry,entry.toURL());
                                console.log("Failed to open URL via Android Intent. URL: " + entry.fullPath);
                            }); 
                        },

插件目前尚不支持任何限制吗?

标签: angularjscordovawebintents

解决方案


推荐阅读