首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cordova plugin-防篡改的Ionic 3实现

cordova plugin-防篡改的Ionic 3实现
EN

Stack Overflow用户
提问于 2019-03-15 13:39:38
回答 2查看 448关注 0票数 1

https://www.npmjs.com/package/cordova-plugin-antitampering

有没有人在他们的项目中实现了这个插件?我已经实现了插件,但是调用了这个函数:

代码语言:javascript
复制
window.cordova.plugins.AntiTampering.verify(
    function (success) {
        console.info(success);
        // {“assets”: {“count”: x}} - where x is the number of assets checked
    },
    function (error) {
        console.error(error);
        // gives you the file on which tampering was detected
    }
);

问题是,函数在成功块中,但计数为0,这意味着插件实际上不会扫描任何文件。我想知道出了什么问题。

提到我所遵循的步骤:

第一步:使用cmd进行安装。命令是: cordova plugin add cordova-plugin-antitampering -variable ENABLE_CORDOVA_CALLBACK=true --save

第二步:使用以下代码调用app.component.ts中的方法:

代码语言:javascript
复制
declare var window: any;

constructor(){
    this.checkTampering();
}  

checkTampering(){
    alert(“Inside Check Tampering”);
    try {
        alert("Inside Try: ");
        window.cordova.plugins.AntiTampering.verify(
            function (success) {
                alert(JSON.stringify(success));
                // {“assets”: {“count”: x}} - where x is                 the number of assets checked
            },
            function (error) {
                alert(JSON.stringify(error));
                // gives you the file on which tampering was detected
            }
        );
    } catch (e) {
        alert("Caught some exception when implementing Integrity check: " + JSON.stringify(e));
    }
}

步骤3:使用以下命令在设备上运行: ionic cordova Run android

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-03-02 20:31:48

很抱歉,我没有在找到解决方案后立即更新此问题。一百多的浏览量意味着你们中的许多人都面临着这个问题。基本上,在应用此插件后,您不必直接运行应用程序。你需要做的就是为Android构建一个APK文件,然后在你的手机上安装APK。这就是成功处理程序返回对象成功的时候:{ "assets“:{ " count”:135 }}(在我的例子中,计数是135取决于你得到的文件数量)这基本上是我的错,我尝试直接运行应用程序,而不是首先构建APK,然后在测试设备上安装它。

票数 2
EN

Stack Overflow用户

发布于 2019-03-15 14:10:51

你有没有尝试过这个的Angular实现?

代码语言:javascript
复制
var app = angular.module('myApproximatelySecureApp', ['duddu.antitampering']);

app.run(['$antitampering', function ($antitampering) {
    $antitampering.verify().then(function (success) {
        console.info(success);
    }, function (error) {
        console.error(error);
    });
}]);

试一试,看看成功的结果是什么。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55176207

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档