Problem Description
If you try to use new lines or similar to create format to a message body, the resultant text in the mail app (either gmail or mail) will be wrongly shown.
Example:
var messageBody = 'I would like to share this awesome app with you: '+
'\n\nApple: http://google.com'+
'\nAndroid: http://google.com'+
'\n\nPlease note, the this app is intended for awesome people '+
'whose employer are awesome. The app '+
'will only work for those who are awesome.';
Will be added to the mail as shown, Ignoring the format.
I would like to share this awesome app with you: %0A%0AApple: http://google.com%0AAndroid: http://google.com%0A%0APlease note, the this app is intended for awesome people whose employer are awesome. The app will only work for those who are awesome.
Steps to reproduce
1. Create a new mobile project Classic Titanium
2. Paste this code to app.js:
var win = Ti.UI.createWindow({backgroundColor:'white'});
var label = Ti.UI.createLabel({text:"click here"});
function doClick(e) {
var messageBody = 'I would like to share this awesome app with you: '+
'\n\nApple: http://google.com'+
'\nAndroid: http://google.com'+
'\n\nPlease note, the this app is intended for awesome people '+
'whose employer are awesome. The app '+
'will only work for those who are awesome.';
var data = {
subject : 'The most awesome App',
recipient : '',
messageBody : messageBody
}
openFeedbackDialog(data);
}
function openFeedbackDialog(emailData){
var subject = emailData.subject;
var toRecipients = [emailData.recipient];
var ccRecipients = [];
var messageBody = emailData.messageBody;
var emailDialog = Ti.UI.createEmailDialog({
subject : subject,
toRecipients : toRecipients,
ccRecipients : ccRecipients,
messageBody : messageBody
}).open();
};
label.addEventListener("click",doClick);
win.add(label);
win.open();
3. Deploy to mobile web, upload it to a webserver.
4. Open that page in your Android within Chrome browser.
5. Click on "Click here"
6. Will open the email dialog, with the wrong text as shown.
Extra information
It only fails if you do the mix "Mobile web + Chrome browser in Android + Mail/Gmail in Android".
Mobile web uses the
mailto:
protocol which the browser will open using the default mail client. Since the email body is put in the URL, it needs to be encoded and thus\\n
becomes%0A
. This is the correct behavior. The problem is Chrome for Android and/or the default Android mail client doesn't properly decode the body. Here's the Chromium bug: https://code.google.com/p/chromium/issues/detail?id=424889. As stated in the Chromium ticket, it appears to have been fixed.Closing ticket as the issue is not our bug.