- Home /
Async parse.com query not working on Android/iOS
When I try to make an asynchronous Parse.com request to fetch data, the task does not seem to get completed. This works within the Unity Editor, but not when running on an Android or iOS device.
I had this working until a few days ago, I re-architected my code a bit and been having trouble since then.
Here's my code snippet:
public void GetFriendScores()
{
StartCoroutine (GetFriendsScoresCoroutine ());
}
IEnumerator GetFriendsScoresCoroutine()
{
Debug.Log("Started friends get scores coroutine");
//Assume these variables contain relevant information
var ids = ............. (string list of facebook IDs)
//Get a list of users who match the friend FB IDs
var usersQuery = ParseObject.GetQuery ("FBUser").WhereContainedIn ("FB_ID", ids);
//Use the user query result to find corresponding high score rows
var scoresQuery = ParseObject.GetQuery ("HiScores").WhereMatchesQuery ("User", usersQuery);
var scoresQueryTask = scoresQuery.FindAsync ();
Debug.Log("Started get scores task");
while (! (scoresQueryTask.IsCompleted))
yield return null;
Debug.List("Get scores task complete");
}
The last line of Debug I see is "Started get scores task", and nothing after that.
When I run it in the editor, I get the correct data and the "Get Scores task complete" message.
Any idea what I might have missed? I'm using Parse 1.5.3 and can confirm that it was working before I re-wrote the code.
After some more trial and error, here's what I noticed:
On iOS, the first time, it freezes at that line, but when I restart the app, it gets past the line.
On Android, it still doesn't go past the "Started get scores task" line, but the app doesn't freeze.
Answer by psykojello2 · Aug 10, 2015 at 01:36 AM
This appears to be fixed with Parse 1.5.4
Answer by hakankaraduman · Jul 19, 2015 at 07:22 PM
any progress with the problem? I also have my app working on editor but not on android
no luck yet. I recommend using ".continueWith()" ins$$anonymous$$d of checking for IsCompleted. That's how I had it working before, but I needed to process the returned data in a loop and continueWith was not working for me. I might redo my code to work with continuewith.
yesterday I was searching for this and in some forum I found out that a lot of people had this problem.
Importing and using 1.3.2 version of Parse SD$$anonymous$$ solved my problem.
Oh, good to know. I had to upgrade to 1.5.2+ because the older ones wouldn't not build on iOS with Unity 5. I might wait for a new patch.
Thanks for letting me know. I did not realize it since I make my tests on my Android phone.
Any updates on this one? on my end, this occurs after upgrading to parse to 1.5.3 D: