简体   繁体   中英

Getting in-app email's subject and message

I've added in-app e-mailing with the MFMailComposeViewController class and it is working well.

I'd like to save what the user enters for the Subject and Message and reload this information the next time the user launches in-app email on the chance they want to re-use their Subject or Message. I haven't found any methods to save this data and am starting to think that it's not possible. Is it?

EDIT: This question did bring up some privacy issues I hadn't thought of. Thanks for the replies.

Not possible using the standard API, with good reason. Things you write in your emails should be sandboxed away from developers who may or may not have your best interest in mind.

There's certainly no obvious public API to get this information; you could try doing something along the lines of waking up on a timer callback and looking through the view hierarchy for the appropriate UITextFields to grab the data out of...

This approach would be subject to the usual uncertainties:

  1. will it work reliably
  2. will Apple reject you for doing it
  3. will it break in the next OS revision

You could take a different approach.

Ask them for the subject and message in your own text input fields BEFORE you bring up the MFMailComposeViewController - and then populate the controller fields with their input.

If they change it in the MFMailComposeViewController you cannot get the NEW information, but you can certainly fill in their new "defaults" in your text input fields the next time around and use this in the MFMailComposeViewController when you pull it up.

I do something similar now, allowing them to set a default To:, Cc:, Bcc: and Subject in their App preferences.

-t

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM