- Home /
Ios problem with www class
enter code here
hey there I wanted to get a xml file from a webserver. It worked perfect for android and pc, but I can't get the connection on ios. I think ios got problems with the www class, but I also think its possible and I've got a mistake in the coroutine. Please have a look at my code, maybe youre able to help me:
Debug.Log("ERROR: " + www.error) shows me "ERROR: ".
crossdomin.xml is on the server
void Start(){
StartCoroutine(StartLoading());
}
IEnumerator StartLoading(){
string url = "http://www.pixcube.com/games_ad/AppData.xml";
WWW www = new WWW(url);
while(!www.isDone)
yield return null;
if (www.error == null){
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(www.data);
ProcessAppLinks(xmlDoc.SelectNodes("AppLinks/AppLink"));
}else{
Debug.Log("ERROR: " + www.error);
}
}
private void ProcessAppLinks(XmlNodeList nodes){
foreach (XmlNode node in nodes){
//get all infos out of the xml node
StartCoroutine(DownloadImage(nodeWithImageWebLink));
}
}
IEnumerator DownloadImage(string url){
WWW www = new WWW(url);
while(!www.isDone)
yield return null;
imageArray.Add(www.texture);
}
Hi Graham; means it won't load the xml. I think the www is returning an error but I'm not sure: Is it possible to Debug.Log trough Xcode at this point while iPad is connected?
You can print something via GUI, at least you see it right on.
Thx for the tip fafase with the GUI. After the first www call I trace out ("ERROR: " + www.error); and it gives me "ERROR: " out. I tested it on iPad and iPhone, same results. It works on Android. $$anonymous$$aybe I've got some wrong export settings:
I think it only gives "ERROR:" because the object holding the error string is destroyed at the end of the StartLoading method. You could try to store the string into a global string:
string message = null;
IEnumerator StartLoading(){
string url = "http://www.pixcube.com/games_ad/AppData.xml";
WWW www = new WWW(url);
while(!www.isDone)
yield return null;
if (www.error == null){
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(www.data);
ProcessAppLinks(xmlDoc.SelectNodes("AppLinks/AppLink"));
}else{
message = www.error;
}
}
void OnGUI(){
GUI.Box(rect, message);
}
Answer by MihajloNen · Dec 21, 2016 at 08:38 PM
I have the same Issues, but not with all WWW requests. I even tried to configure xCodes NSAppTransportSecurity to allow http downloads. Nothing helped. If smo. know a better solution pls help. Thank's