Ionic 3 cordova插件防夹的实现
有人在他们的项目中实现了这个插件吗? 我已经实现了这个插件,但是调用了这个函数:Ionic 3 cordova插件防夹的实现,cordova,ionic-framework,ionic3,Cordova,Ionic Framework,Ionic3,有人在他们的项目中实现了这个插件吗? 我已经实现了这个插件,但是调用了这个函数: window.cordova.plugins.AntiTampering.verify( function (success) { console.info(success); // {“assets”: {“count”: x}} - where x is the number of assets checked }, function (error) {
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插件添加cordova插件防夹--变量ENABLE\u cordova\u CALLBACK=true--保存
步骤二:使用以下代码调用app.component.ts中的方法:
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您是否已经尝试过此功能的角度实现
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);
});
}]);
尝试一下,看看成功的结果是什么。很抱歉,我没有在找到解决方案后立即更新此问题。100多个视图意味着你们很多人都面临这个问题。基本上,你不必在应用这个插件后直接运行应用程序。 你所需要做的就是为Android构建一个APK文件,然后在你的手机上安装APK。 此时,成功处理程序返回对象success,如下所示: {“资产”:{“计数”:135} (135在我的例子中,计数取决于您获得的文件数)
这基本上是我的错,我尝试直接运行应用程序,而不是首先构建一个APK,然后将其安装到测试设备上。在ionic 3中,我在哪里添加这个?在app.component.ts或app.module.ts中?另外,$antitampering让我想起Angular JS,我正在使用离子3中的Angular 6。你确定这是我需要实现的部分吗?因为根据这里的文档:“如果您使用AngularJS(例如与Ionic一起使用),您可以使用插件提供的angular服务$antitampering;”,这表明Ionic 1。