Get default user email in iOS Device

前端 未结 2 1570
暗喜
暗喜 2020-12-19 02:39

Is it possible to retrieve the user email associated with the default email account directly from an app?

Screenshot:

相关标签:
2条回答
  • 2020-12-19 02:50

    In addition to @woz answer, this is a gist that can help you.

    In my app, I have a feedback form to let users could get in touch with me. Unfortunately, many users had minor misspellings in their email addresses and I couldn't reach back to them.

    As I couldn't get a perfect way to be sure the email was correct, I've developed the following gist which:

    1. asserts the mail is a proper foo@bar.tld
    2. verifies that the email is contained in the user's address book
    3. if not, suggests the closest match

    Again, this is far from perfect and I only included this behavior optionally (a little 'check mail' button next to the UITextField)

    https://gist.github.com/dirtyhenry/7547064

    0 讨论(0)
  • 2020-12-19 02:54

    I can't prove a negative, but I am fairly certain this is not possible. You can use MFMailComposeViewController to allow the user to send an email from the default account, but you cannot directly access information about the default account. If you need the user's email address, you either have to ask for them to type it in, or have them select it from their contacts.

    0 讨论(0)
提交回复
热议问题