Get default user email in iOS Device

删除回忆录丶 提交于 2019-11-28 03:34:01

问题


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

Screenshot:

Thanks.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/10758431/get-default-user-email-in-ios-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!