views:

159

answers:

3

I need to be able to give users the ability to call someone or email someone from a certain view in my navigation based app.

I thought I would use an action sheet with the choices and depending on the button pressed allow one or the other to be initiated (I'm simplifying a lot but ...).

I really have several questions.

  • Assuming this is possible to do, will my app be gone after a phone call is started?
  • Is there a way for me to launch/push on the stack the same "controller" and "view" that Apple uses for making calls and sending emails? Or am I going to have to code this all myself to look like their app?
  • I want the user to come back to the same page they were on when the email or phone call was initiated. How can I do that or is my app gone if I use their controller and nib?
  • Assuming it's possible to do either of these things, can I put the email address I want for a default in the to: field of the email view and if so how?
A: 

unfortunately if you make a phone call then the application is terminated. For email however, I believe there is a framework or something to do that, I think it's in the messaging API, but I'm not 100% sure as whenever I use email stuff I just do a mailto: url (which closes the app)

Matt S.
A: 

You can not make a phone call from within you application without exiting your app.

You can send an email inside your application using MFMailComposeViewController. Your application will remain at whatever view it was at when you present the Mail Compose View Controller view. You can set all of the normal fields in an email (subject, recipients, cc, bcc, body, ect...).

JWD
+1  A: 

Here are the answers to your questions:

  • Assuming this is possible to do, will my app be gone after a phone call is started?

Yes.

  • Is there a way for me to launch/push on the stack the same "controller" and "view" that Apple uses for making calls and sending emails? Or am I going to have to code this all myself to look like their app?

Yes. MFMailComposeViewController for Mail, and [[UIApplication sharedApplication] openURL:[NSURL URLWithString:telephoneText]] for a Call

  • I want the user to come back to the same page they were on when the email or phone call was initiated. How can I do that or is my app gone if I use their controller and nib?

For Mail this can be accomplished with MFMailComposeViewController. It's not possible for a telephone Call.

  • Assuming it's possible to do either of these things, can I put the email address I want for a default in the to: field of the email view and if so how?

Yes.

You can look at the sample code https://developer.apple.com/iphone/library/samplecode/MailComposer/index.html or the tutorial http://blog.mugunthkumar.com/coding/iphone-tutorial-in-app-email

Jordan
For a telephone call, you can put code in - (void)applicationWillResignActive:(UIApplication *)application and - (void)applicationWillTerminate:(UIApplication *)application to save state, and on launch, you can then restore state.
Jordan