Mailto: link issues, can't easily get back to app after finishing email (iOS)


#1

I have a simple link in a Contact Us screen to fire the phone’s email client (iOS 7)

<div class="list">
  <a class="item item-icon-left" href="mailto:example@gmail.com">
    <i class="icon ion-ios7-email"></i>Email
  </a>
  <a class="item item-icon-left" href="sms:087111111111">
    <i class="icon ion-chatbox-working"></i>SMS
  </a>
</div>

It works fine except one thing - when I finish my email (or abort it), I’m left in the email app and there is no easy way to return to my own app (i.e. the one I’m developing in Ionic) apart from launching it from the home screen again. In Android, if I abort my email with the back button, I just return to my app, just where I left off.

Similar issue with sms: or tel: links.

Is this an iOS vs Android issue, or something I can easily make a better user experience?


#2

that’s default behavior in ios/android.

for email im using email-composer https://github.com/jcjee/email-composer
with this you will still be in your app after writing.

and with this i call it:

if (window.plugins && window.plugins.emailComposer) {
    window.plugins.emailComposer.showEmailComposerWithCallback(function(result) {
          console.log("Response -> " + result);
     },
                    "Feedback: version: 1.0.0", // Subject
                    "",                      // Body
                    ["email@superduper.com"],    // To
                    null,                    // CC
                    null,                    // BCC
                    false,                   // isHTML
                    null,                    // Attachments
                    null);                   // Attachment Data
}

for sms/tel im not sure if there is a same plugin


#3

Hi, thanks for that.

I added EmailComposer.js to my index.html, and put you code into the relevant controller, but

if (window.plugins && window.plugins.emailComposer)

is returning false (I added in extra logs to check the function is being called, and in a false branch of the if statement)

Only testing in Chrome so far.

WORKING NOW

Works when I install on devices, thank you!


#4

yep plugins do not work in chrome!
but im not sure if they work in simulator.


#5

Auro, it works for me in the iOS sim


#6

okey good to know :smiley:


#7

I just tried this mailto-link myself and nothing happens in the web preview or the ios simulator. Is that normal or is something wrong?


#8

As discussed above, only seems to work on an actual device or emulator - did you try that?


#9

@kevin432 oh! No I didn’t. I don’t know how to actually. I only have an iphone and I still haven’t tried to build anything in my development learning project.


#10

In that case I’d just use a normal HTML link as I did, at the top of this post. Both methods work fine, the only advantage of the plugin is that the user is taken back to the app once you finish your email.

You will also find that SMS and TEL links do not work outside a device too.

EDIt - I forgot that the email plugin also works on the iOS emulator, sorry for posting incorrect info. Have you got X code installed on a mac?


#11

Yep I use a mac and I have xcode installed. (never used it though)