2

I want to build an app in swift to send sms or email on scheduled date and time and the data need to be stored in database. I know we need to use MFMessageComposeViewController or MFMailComposeViewController for sending sms/email but how to send only on scheduled date?

For example: I want to schedule a sms for birthday wish of my friend on his birth date and let the app send the message on that specific date or time.

Can somebody share any tutorials related to this type of questions?

Eltaf Hussain
  • 3,071
  • 1
  • 14
  • 20
  • 2
    You can only do that if you have a backend that can send mail and SMS. Sending a mail or a SMS has do be done and particularly validated (end action) by the user (in order to avoid spam/useless/unwanted messages). There is no method given to send a message with delay in iOS. – Larme May 01 '16 at 20:01
  • Thanks for the response. By backend you mean, we need to use third party API or we have to build some background running code to perfume delayed action? – Eltaf Hussain May 01 '16 at 20:22
  • Can you please suggest me any related article or tutorials that could help me out? I have been searching and unable to find the relevant one. – Eltaf Hussain May 01 '16 at 20:27

1 Answers1

2

It sounds like you're trying to send emails and texts without prompting the user to fill in their content. The classes you mentioned are used to present views that allow the user to fill in the message content, like shown below.

MFMessageComposeViewController MFMailComposeViewController

If you would like to send email from the app without using the users email address and allowing them to fill in the content, you'll need to use an email service that provides an API, like Mailgun.

Unfortunately, you won't be able to send emails when the app is in the background. To do this, you should use a backend server to schedule emails.

Mike Buss
  • 980
  • 9
  • 25
  • Thanks for the response, Yes I get your suggestion I have been reading them. Is there any related tutorials or link that you can suggest me? – Eltaf Hussain May 01 '16 at 20:25
  • 1
    Here's a library you can use to send email through Mailgun using Objective-C, which should also work with Swift: https://github.com/rackerlabs/objc-mailgun - The README file contains an example. – Mike Buss May 01 '16 at 20:39