Why is this simple C# script not working?

[I have asked Prime31, and they only replied that the return is indeed a string, offering no other information]

Using Prime31s Social Networking iOS Plugin – I can confirm that permissions ARE granted (and in fact the script’s debug log shows the same). The problem is that the script doesn’t seem to be triggering the part that sets my variables to true. I can’t seem to figure out why. Granted I’m new to C#, so it could just be a dumb mistake.

The Code:

IEnumerator CheckPermissions()
		while (!canPublishStream || !canPhotoUpload)
			var permissions2 = FacebookBinding.getSessionPermissions();
			foreach( var perm2 in permissions2 )
				if (perm2 == "publish_stream")
					canPublishStream = true;	
				if (perm2 == "photo_upload")
					canPhotoUpload = true;	
				print ("A permission2: " + perm2 + " ( " + canPublishStream + " / " + canPhotoUpload + " )");
			yield return new WaitForSeconds(5);

XCode provides a slew of information, showing I have permission for a bunch of stuff. However, the results below show what confuses me: that perm2 sure does equal the variable (publish_stream) or (photo_upload), but the true statements were not triggered.

A permission2: photo_upload ( False / False )

I’m wondering if perm2 isn’t actually a string data type? I know you say you confirmed that, but maybe they were confused about what you were asking. Try this…

foreach (string perm2 in permissions2)
  // your if statements here


if (perm2.ToString() == "photo_upload")...

Are you sure the script is starting? Is it a container on a Empty?

You said that perm2 really contains “photo_upload”, but how did you check if that’s really true? There could be a line break, a space, maybe a null character in the string. Add this at the end of your print statement:

    + " L:" + perm2.Length);

It should give you “L:12” for “photo_upload” and “L:14” for “publish_stream”. If not the string is not equal.

To fix this you chould try adding something like this inside your for-loop:

    perm2 = perm2.Trim().ToLower();

Of course before you do your if statements :wink:

ps: I’m just wondering, when none of the bool variables turn true you should see the print every 5 sec, right?