I’m trying to use the shareViaEmail
method from a button on an $ionicPopup. For some reason it is not working on iOS. It works perfectly fine on Android though. I can get console logs when the button is clicked but, the email app is never triggered to open. Here is the code I’m using for that section:
function ($ionicPopup, $cordovaSocialSharing, $cordovaDevice, $http, $timeout) {
var _getDeviceData = function() {
var deviceData = $cordovaDevice.getDevice();
if(deviceData !== 'undefined' || deviceData !== null) {
return '\n \n \n --- Please enter your message above --- \n Platform: ' + deviceData.platform + '\n OS Version: ' + deviceData.version + '\n Cordova Version: ' + deviceData.cordova + '\n Device Model: ' + deviceData.model;
} else {
return 'No device data was available.';
}
};
var _openEmailShare = function(shareMessage) {
if (shareMessage && window.plugins && window.plugins.socialsharing) {
$cordovaSocialSharing.shareViaEmail(shareMessage, 'Support Request', ['support@someEmail.com'], [], [], null)
.success(function(success) {
console.log('success!')
}).error(function(err) {
console.log(err);
});
} else {
console.log('email share was not available.')
}
};
var _buildModal = function(faqs, _scope) {
// if the data comes back successfully, build modal
var faqModal = $ionicPopup.show({
title: 'FAQs',
template: '<div ng-repeat="faq in faqs" class="faq-container"><h3 class="faq-question">{{faq.question}}</h3> {{faq.answer}}</div>',
scope: _scope,
buttons: [
{
text: 'Close',
type: "button white close-modal full-width padding-top padding-right"
},
{
text: 'Contact Support',
type: "button green close-modal full-width padding-top",
onTap: function (e) {
e.preventDefault();
console.log('after preventDefault')
// THIS IS THE LINE THAT IS NOT FIRING
_openEmailShare(_getDeviceData());
}
}
]
});
}; // end _buildModal
// Show FAQ popup
this.showFAQModal = function(_scope) {
$http.get('http://www.somesite.json')
.success(function(response) {
_scope.faqs = response.faqs;
}).error(function(error, status) {
_scope.faqs = [{ question: 'OHNO! Something went wrong, please try again.'}];
});
_buildModal(_scope.faqs, _scope);
};
}]);
Any idea why this wouldn’t work on iOS?