Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send an email through iOS simulator?

I want to know if it's possible to send email through iPhone simulator. I have seen the tutorial for sending an email through iphone as below:

http://www.edumobile.org/iphone/iphone-programming-tutorials/compose-mail-application-in-iphone/

Now to test it is it necessary to have real device? What is the way if I want to send email through iPhone simulator?

like image 685
nehal Avatar asked Mar 18 '11 07:03

nehal


People also ask

Can we send push notification to iOS simulator?

Yes, that's true. I always wondered if I can send a Push Notification on iOS simulator instead getting a real device while developing applications. Simulator supports simulating remote push notifications, including background content fetch notifications.

How do you tap in iOS simulator?

When in the simulator, hold the option key down and click - this will simulate a two-finger tap!

How do I send push notifications to simulator?

In Simulator, drag and drop an APNs file onto the target simulator. The file must be a JSON file with a valid Apple Push Notification Service payload, including the “aps” key. It must also contain a top-level “Simulator Target Bundle” with a string value matching the target application's bundle identifier.


1 Answers

You have to rely on the iOS that the MFMailComposeResult that is handed back in mailComposeController:didFinishWithResult:error: is correct. The simulator fakes that result; no actual mail is sent although it says MFMailComposeResultSent.

The tutorial mentioned misses an important point: The first thing you should do before using MFMailComposeViewController is to check [MFMailComposeViewController canSendMail]. That will return NO, if the user hasn't configured mail on their device. If you must support an iOS version prior to 3.0 the correct way is to check if the class MFMailComposeViewController exists:

Class mailClass = (NSClassFromString(@"MFMailComposeViewController")); if (mailClass != nil) {     if ([mailClass canSendMail])     {         [self displayComposerSheet];     }     else     {         [self launchMailAppOnDevice];     } } else {     [self launchMailAppOnDevice]; } 

The canSendMail-issue can only be tested on a real device though. It will crash if you don't check canSendMail and the user has no mail account configured.

like image 126
Felix Avatar answered Sep 22 '22 22:09

Felix