Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get default user email in iOS Device

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

Screenshot:

enter image description here

Thanks.

like image 716
Jeremy Grenier Avatar asked May 25 '12 16:05

Jeremy Grenier


People also ask

What is default email on iPhone?

The first email you add to the iPhone Mail app becomes your default. This means that when you compose a new email or click on an email address on a website or app, it opens with this default email in the 'From' section.

What is a default account for email?

Your default email account is simply your primary email account. The email will appear when you tap the “compose” email icon.


2 Answers

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.

like image 76
woz Avatar answered Oct 18 '22 13:10

woz


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 [email protected]
  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

like image 28
Dirty Henry Avatar answered Oct 18 '22 14:10

Dirty Henry