I am working on an Ionic Android / iOS application that will primarily be used to scan barcodes, and then send an attachment containing all the checks to a distribution group in a CSV file (.txt). This application uses the ngCordova + Cordova Email Composer plugin (cordova-plugin-email-composer) to work with email. After starting sending email in Android (6.0.1 on Nexus 5), I get the following console error:
TypeError: $ cordovaEmailComposer.isAvailable is not a function
All other processes work correctly (for example, the correct generation of file paths, formatting and generation of attachments) and the plug-in for the ngCordova + Cordova barcode plug-in (phonegap-plug-barcodescanner) function correctly.
I had some problems with Cordova Email Composer v0.8.3, always returning "false" on .isAvailable () on Android, however I successfully worked on this using v0.8.2. This new issue occurs in both versions.
Below is the part of the Angular service that contains the problem code. scanData- This is a simple service that temporarily contains scanned information, including paths and an array of all scans. processFile- this is a service that processes all file processing (for example, saves, downloads, deletes, dynamically generates a file name, determines the correct path to the file).
angular
.module('app')
.factory('emailService', ['$ionicPlatform', '$ionicPopup', '$ionicHistory', '$cordovaEmailComposer', 'scanData', 'processFile', emailService]);
function emailService($ionicPlatform, $ionicPopup, $cordovaEmailComposer, $ionicHistory, scanData, processFile) {
var path = scanData.filePath,
file = scanData.fileName;
var service = {
send: send
};
return service;
function send() {
processFile.save('csv')
.then(function () {
console.info('CSV file saved.');
sendEmail();
}, function (error) {
console.error(error);
});
}
function sendEmail() {
console.info('Sending email...');
$ionicPlatform.ready(function () {
$cordovaEmailComposer
.isAvailable()
.then(function () {
console.info('Email app available.');
var attachmentPath = getAttachmentPath();
console.info('Attachment path: ' + attachmentPath);
var email = {
to: 'foo@bar.com',
attachments: [ attachmentPath ],
subject: 'Incoming Scan',
body: 'See attached.'
};
$cordovaEmailComposer
.open(email)
.then(null, function () {
clearDataPopup();
});
}, function () {
console.warn('Email app not available.');
});
});
}
, / , ionic state reset . iOS, , . Android - , .
, - , , .