Angularjs Cordova屏幕截图未按时运行$IonicView.Enter
我们正在爱奥尼亚进行一个iOS项目。我们希望cordova屏幕截图插件在ionicview enter上启动(当第一次进入应用程序时),然后使用cordova文件传输发送屏幕截图 第一次进入视图时,以下代码不起作用。然而,当我们离开视图返回时,它确实会发送一个屏幕截图 但是,第一个logAction会在第一次进入此视图时触发,而第二个logAction不会。当第二次进入此视图时,两个日志操作都被触发 这是我指的代码的一部分:Angularjs Cordova屏幕截图未按时运行$IonicView.Enter,angularjs,cordova,ionic-framework,cordova-plugins,Angularjs,Cordova,Ionic Framework,Cordova Plugins,我们正在爱奥尼亚进行一个iOS项目。我们希望cordova屏幕截图插件在ionicview enter上启动(当第一次进入应用程序时),然后使用cordova文件传输发送屏幕截图 第一次进入视图时,以下代码不起作用。然而,当我们离开视图返回时,它确实会发送一个屏幕截图 但是,第一个logAction会在第一次进入此视图时触发,而第二个logAction不会。当第二次进入此视图时,两个日志操作都被触发 这是我指的代码的一部分: $scope.$on('$ionicView.enter', func
$scope.$on('$ionicView.enter', function () {
$scope.logAction({
"Message": "Login screen succesfully entered",
"Succeeded": true,
"transaction": 1,
"Category": "Info",
"Device": 0,
})
$cordovaScreenshot.capture().then(function(filepath){
$scope.logAction({
"Message": filepath,
"Succeeded": true,
"transaction": 1,
"Category": "Info",
"Device": 0,
})
$cordovaScreenshot.send(filepath);
});
});
这是Cordova屏幕截图文件
angular.module('testScreenshots.services', [])
.service('$cordovaScreenshot', ['$q',function ($q) {
return {
fileURL: "",
capture: function (filename, extension, quality) {
var randomNumber = Math.random();
console.log("" + randomNumber);
filename = "testPicture" + randomNumber.toString();
extension = extension || 'jpg';
quality = quality || '100';
var defer = $q.defer();
navigator.screenshot.save(function (error, res){
if (error) {
console.error(error);
defer.reject(error);
} else {
console.log('screenshot saved in: ', res.filePath);
this.fileURL = "file://" + res.filePath;
defer.resolve(res.filePath);
console.log("inside the save function: "+this.fileURL);
}
}, extension, quality, filename);
return defer.promise;
},
send: function(filepath){
var win = function (r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
}
var fail = function (error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = filepath.substr(filepath.lastIndexOf('/') + 1);
options.mimeType = "multipart/form-data";
options.chunkedMode = false;
options.headers = {
Connection: "close"
};
var ft = new FileTransfer();
ft.upload(filepath, encodeURI("http://192.168.6.165:8080//api/uploadpicture"), win, fail, options);
}
};
}])
我们在Mac上使用的iOS模拟器有这个问题。在尝试在设备上运行后,该问题不再影响我们
因此,这个问题似乎与使用iOS模拟器有关。我们在Mac上使用的iOS模拟器有这个问题。在尝试在设备上运行后,该问题不再影响我们 因此,这个问题似乎与使用iOS模拟器有关