Help with code

Discussion in 'iOS Programming' started by Jim mason, Aug 15, 2018.

  1. Jim mason macrumors newbie

    Jim mason

    Joined:
    Sep 24, 2017
    #1
    Hi guys
    I am very new to swift, and have created a very basic app but I am stuck on coding it and cannot find the answer in Xcode help files
    Basicly there is a submit button and a text box were you enter vehicle registration, what I need to code is when submit button pressed it sends whatever registration is in the text box to my email address, can anyone point me in the right direction to code this
    Many thanks.
     
  2. mds1256 macrumors regular

    Joined:
    Apr 9, 2011
    #2
    Couple of different ways, you can code it so it opens a new email in the mail client on the device (however not everyone has Mail set up on their device).

    The better way of doing it is to create a web service which you 'post' to on submit that will send the email for you.

    For example, you can use something like send grid as a webservice (https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html) and create a url request when you press the button on the screen to post the data to SendGrids web api to send the email on your behalf.
     
  3. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #3
    As mds1256 mentioned, you could open a mail window and populate with the information. For that look up MFMailComposeViewController and its delegate. There is NOT an option to hide the window and send the email in the back ground. I suppose there could be a third party library that could send a hidden email.

    That leaves setting up a server that your app can communicate with.
     
  4. jimmason macrumors newbie

    Joined:
    Sep 2, 2012
    Location:
    Hertfordshire
    #4
    Thanks for reply's guys, I will have a look in the morning and see if I can get it to play ball.
     

Share This Page