From 5e954457a795f77804ccaef74c8012aac50d765b Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Sat, 27 Oct 2018 09:59:58 -0400 Subject: switch to diff email plugin to allow attachments properly --- config.xml | 2 +- package.json | 7 ++++--- www/js/LogCtrl.js | 52 +++++++++++++++++++++++++++------------------------- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/config.xml b/config.xml index 07eca852..9d571b45 100644 --- a/config.xml +++ b/config.xml @@ -146,7 +146,6 @@ - @@ -167,6 +166,7 @@ + diff --git a/package.json b/package.json index da5e2c6c..c6ce98da 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "cordova-plugin-device": {}, "cordova-plugin-file": {}, "cordova-plugin-media-pp-fork": {}, - "cordova-plugin-email": {}, "cordova-plugin-statusbar": {}, "cordova-library-helper-pp-fork": {}, "cordova-plugin-multi-window": {}, @@ -53,7 +52,8 @@ "cordova-plugin-ionic-webview": { "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+" }, - "cordova-plugin-advanced-websocket": {} + "cordova-plugin-advanced-websocket": {}, + "cordova-plugin-x-socialsharing": {} } }, "dependencies": { @@ -70,7 +70,6 @@ "cordova-plugin-cloud-settings": "^1.0.4", "cordova-plugin-customurlscheme": "^4.3.0", "cordova-plugin-device": "^2.0.1", - "cordova-plugin-email": "^1.2.7", "cordova-plugin-file": "^6.0.1", "cordova-plugin-file-transfer": "^1.7.1", "cordova-plugin-globalization": "^1.0.7", @@ -90,9 +89,11 @@ "cordova-plugin-touch-id": "^3.2.0", "cordova-plugin-websocket": "^0.12.2", "cordova-plugin-whitelist": "^1.3.2", + "cordova-plugin-x-socialsharing": "^5.4.1", "cordova-sqlite-storage": "^1.5.3", "deep-equal": "^1.0.1", "electron-window-state": "^4.1.1", + "es6-promise-plugin": "^4.2.2", "jsonfile": "^4.0.0", "keypress": "^0.2.1", "menu": "^0.2.5", diff --git a/www/js/LogCtrl.js b/www/js/LogCtrl.js index cba597ed..e87b8034 100644 --- a/www/js/LogCtrl.js +++ b/www/js/LogCtrl.js @@ -106,11 +106,7 @@ angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$roo $scope.attachLogs = function() { - cordova.plugins.email.isAvailable( - function (isAvailable) { - - if (isAvailable) { - + var body = "zmNinja version:" + $scope.zmAppVersion + " (" + $rootScope.platformOS + ")
" + @@ -124,33 +120,39 @@ angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$roo .then (function (d) { var url = cordova.file.dataDirectory + d.name; + //url = url.replace("file://",""); console.log ( "URL:"+url); - cordova.plugins.email.open({ - to: zm.authoremail, - subject: $rootScope.appName + ' logs attached', - body: body, + NVRDataModel.log ( "URL:"+url); + + + var onSuccess = function(result) { + NVRDataModel.log("Share completed? " + result.completed); // On Android apps mostly return false even while it's true + NVRDataModel.log("Shared to app: " + result.app); // On Android result.app since plugin version 5.4.0 this is no longer empty. On iOS it's empty when sharing is cancelled (result.completed=false) + }; + + var onError = function(msg) { + NVRDataModel.log("Sharing failed with message: " + msg); + }; + + window.plugins.socialsharing.shareViaEmail( + body, //body + 'zmNinja Logs attached', // subject + [zm.authoremail], //to + null, // cc + null, //bcc + [url], + onSuccess, + onError + ); + + - attachments: url - - }); }, function (e) { NVRDataModel.debug ("Error attaching log file:"+JSON.stringify(e)); }); - - - } else { - // kEmailNotConfigured - $rootScope.zmPopup = SecuredPopups.show('alert', { - title: $translate.instant('kError'), - template: $translate.instant('kEmailNotConfigured'), - okText: $translate.instant('kButtonOk'), - cancelText: $translate.instant('kButtonCancel'), - }); - } - - }); + }; //-------------------------------------------------------------------------- // Convenience function to send logs via email -- cgit v1.2.3