tzeejay icon

About

Archive

Github

iOS' Share Sheet Is Broken For E-Mail

The share sheet that we use daily in iOS was first introduced almost ten years ago, it appears though that enabling users to share basic things like formatted plain text, the one thing E-Mail is most used for, via their preferred E-Mail client is seemingly still an afterthought. It appears that either nobody is able to implement these APIs correctly or nobody is interested to do so. Variables needed to be set via undocumented KVC calls, or by prepending your text with whitespace characters. Obviously these workarounds can be found in Apple’s great developer documentation in which they clearly communicate these shortcomings…. ah no wait I am just joking, actually you can find it in comments under answers to StackOverflow questions.

How is anybody willing to tolerate this shit?

At Guardian we try to make it as easy as possible for our customers to send a support inquiry from our app via their E-Mail account so that they have full control over what information is shared with our support staff. Opt-in instead of opt-out! No hidden data mining!

Guardian Contact Technical Support UI Guardian Contact Technical Support Formatted E-Mail

Every once in a while we get requests from users asking us to support E-Mail clients other than the builtin iOS Mail.app. Some prefer GMail, Fastmail or Outlook and we would like to make it easy for all customers to help us help them. We would like to conform to a system protocol (like UIActivityItemSource but useful) which allows us to set the recipients E-Mail address, the subject line and the body. Setting the E-Mail’s body is the only thing that actually works reliably. Instead we end up with a mess in which the iOS Mail.app supports an undocumented KVC call on the UIActivityViewController instance that you created to set the subject line pre iOS 13, since it is undocumented GMail does not support that but if you add lots of return characters \n to your E-Mail body string GMail will not place your body string into the subject line and I am convinced that other apps have other problems as well.

I do not understand why the three required (yeah technically two, but who doesn’t set a subject) fields in an E-Mail cannot be set programmatically by an app. With iOS 13 Apple added activityViewController: subjectForActivityType: which allows you to set a subject line but in my testing neither GMail nor Fastmail actually support it. Maybe them not supporting it isn’t even intentional, maybe they can’t because Apple also didn’t bother to document how E-Mail clients are supposed to handle this new value. Who knows…

So instead of using system functionality that is always presented to the user in the same way and would reduce a lot of friction on both ends, we now have the choice of supporting no other E-Mail client like we currently do or add a bunch of URL schemes to deep link into various other apps like it’s 2010. What a time to be an iOS developer.

25.03.2021