Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can't send email in iOS build

Discussion in 'Scripting' started by Samssonart, Jan 18, 2013.

  1. Samssonart

    Samssonart

    Joined:
    Dec 14, 2011
    Posts:
    25
    Hi,
    I'm working on a multi platform game, Web Player, Android and iOS , the game generates image bytes using RenderTexture, sends the bytes to a server and then the server creates the actual image and emails it. The script works great on both Web and Android, but doesn't on iOS. Here´s the relevant code:
    Code (csharp):
    1.  
    2.                HUDMobile.isProcesing = true;
    3.         yield return new WaitForEndOfFrame();
    4.         WWWForm form = new WWWForm();
    5.         //here goes some code to generate a random name, omitted
    6.         ref_link_screenshot = s_name;
    7.         RenderTexture.active = screenShot;
    8.         tmpTexture.ReadPixels(new Rect(0,0, screenShot.width, screenShot.height),0,0);
    9.         tmpTexture.Apply();
    10.         form.AddField("frameCount", Time.frameCount.ToString());
    11.         form.AddBinaryData("file", tmpTexture.EncodeToPNG(), s_name, "image/png");
    12.        
    13.        
    14.         WWW w = new WWW(ref_link_screenshot_download, form);
    15.         yield return w;
    16.        
    17.        
    18.         if (w.error != null)
    19.         {
    20.             Application.ExternalCall("MessageError", w.error);
    21.             //Debug.LogError("Error uploading image: "+w.error);
    22.             HUDMobile.isProcesing = false;
    23.         }
    24.         else
    25.         {
    26.            
    27.             Debug.Log(ref_link_screenshot_email+"?i=ScreenShots/"+s_name+"&email="+mail);
    28.             WWW sendMail = new WWW(ref_link_screenshot_email+"?i=ScreenShots/"+s_name+"&email="+mail); 
    29.            
    30.             yield return sendMail;
    31.            
    32.             if(sendMail.error != null)
    33.             {
    34.                 Debug.Log("error sending mail: " + sendMail.error);
    35.             }
    36.             else
    37.                 Debug.Log("Everything went fine: " + sendMail.text);
    38.             HUDMobile.isProcesing = false;
    39.         }
    I´ve noticed that the image is actually being generated and uploaded to the server, and I even get the log text stating that it went fine, but no mail at all. Also, sendMail.text contains HTML code, i tried a gmail address, and the HTML appeared to be gmail's front page. Has anyone ever encountered a similar problem? What can I do? IS there something special to do in iOS with www?
     
  2. Dmitry-Pyalov

    Dmitry-Pyalov

    Joined:
    Dec 13, 2011
    Posts:
    125
    Could it be a problem in your server? Did you try to monitor, what kind of request do you get on server? Could it be malformed?

    You can try to set up Fiddler Debugging Proxy on the PC and configure your iOS device to use it. Then you can monitor, what kind of requests and responses do really happen.
     
  3. Samssonart

    Samssonart

    Joined:
    Dec 14, 2011
    Posts:
    25
    Thanks Dmitry, yes I checked that as well, I logged the full URL to which the request was made, copy-pasted it in a browser and worked, it did send the email and all.