Search Unity

[Webplayer][Facebook][Crossdomain]Unity Webplayer, Facebook Canvas Crossdomains...

Discussion in 'Editor & General Support' started by plasticYoda, Oct 24, 2013.

  1. plasticYoda

    plasticYoda

    Joined:
    Aug 20, 2013
    Posts:
    62
    I've run into a problem trying to get a Unity App which is running on a Facebook canvas to access my external server using WWW in a co-routine as follows:

    Code (csharp):
    1.  
    2.     IEnumerator FetchFromURL(string url, Action<WWW>parseResult) //Func<string,int> parseResult)
    3.     {
    4.         WWW www = new WWW(url);
    5.         yield return www;
    6.         //Debug.Log("URL responded with: " + [url]www.text);[/url]
    7.         parseResult(www);
    8.     }
    9.  
    I've placed the required crossdomain.xml in the root of my server, and when I run the above code via the editor, it works as expected. If the crossdomain file is missing or incorrect, then I get an error, as expected.

    However, when I run the App via a Facebook canvas the WWW never fetches the result - I've no idea why, and I'm hoping someone here does.

    Other tests we've performed: Running the App as a standalone web player - works as expected. Running the App as a standalone web player delivered from our server (the same server that delivers the .unity3d file to the facebook canvas), works as expected.

    Just to add insult to injury, the same App is using Parse to send information to my Parse setup, and that works fine either on the FB canvas or in any standalone deployment....
     
  2. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    135
    Same issue.

     
  3. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    135
    Got it. Found this on another thread. You need to setup your crossdomain.xml to allow secure is false if your not making your call via https. Worked fine once I modded it.

    <?xml version="1.0"?>
    <cross-domain-policy>
    <allow-access-from domain="*" secure="false"/>
    </cross-domain-policy>
     
  4. plasticYoda

    plasticYoda

    Joined:
    Aug 20, 2013
    Posts:
    62
    Thanks -- I'll check into that -- I ended up writing a parse cloud function to fetch the URL I wanted and return it to Unity...
     
  5. EricJ13

    EricJ13

    Joined:
    Feb 28, 2009
    Posts:
    355