Free AI web copilot to create summaries, insights and extended knowledge, download it at here
1693
Abstract
nting the email composer interface in the step 4.</p>
<figure id="7052">
<div>
<div>
<iframe class="gist-iframe" src="/gist/sullivan1996/e8403937d55f3a6165554e501e1fccd9.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
</div>
</div>
</figure></iframe></div></div></figure>
<figure id="f02a">
<div>
<div>
<iframe class="gist-iframe" src="/gist/sullivan1996/2151b15ffb514f748ce6a9d35b0cbaa7.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
</div>
</div>
</figure></iframe></div></div></figure><h2 id="f927">Step 3: Add the MFMailComposeViewControllerDelegate Method</h2><p id="2284">Add this extension at the end of your ViewController, after the last graph. This method is responsible for calling the mail ViewController delegate directly from your app, that way, you don’t need to build a custom email composer. The different cases covers the majors’ scenarios: the user cancel, the email failed to be delivered (internet connection for example), the user save the email or he sends it.</p>
<figure id="f5e7">
<div>
<div>
<iframe class="gist-iframe" src="/gist/sullivan1996/34a8ed34a14087f4d211a4ad4ee9b5d5.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
</div>
</div>
</figure></iframe></div></div></figure><h2 id="16ad">Step 4: Present the email composer</h2><p id="825e">Last steps: give the action to
Options
the button, copy/paste the code below to the view controller. Inside the function below, we cover the basics: we set the recipient, the subject, and the body but you can also add an attachment to the email with the .addAttachmentData() method.</p>
<figure id="3e0c">
<div>
<div>
<iframe class="gist-iframe" src="/gist/sullivan1996/46f0f3c2ed590cee3c420c85e8f0470f.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
</div>
</div>
</figure></iframe></div></div></figure><h2 id="826b">Step 5: Get on your phone!</h2><p id="5e6e">The simulator often doesn’t support the presentation of the mail composer, run the app with your personal device and click on the button — you should be able to see the mail composer screen appears with an email ready to be sent!</p><blockquote id="b1a5"><p><b>Thanks for reading! I’m always happy to have a chat and collaborate at <a href="mailto:[email protected]">[email protected]</a>. Consider subscribing to enjoy unlimited access to my articles and all of Medium <a href="https://sullivan-decarli.medium.com/membership">through my referral link</a></b></p></blockquote><p id="30fe">You can find the complete piece of code below, thanks for reading!</p>
<figure id="e463">
<div>
<div>
<iframe class="gist-iframe" src="/gist/sullivan1996/0003c7d6c88c3a7e78a802f4528b7d9d.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
</div>
</div>
</figure></iframe></div></div></figure></article></body>