- Home /
Open facebook app instead safari / iOS - C#
I'm trying to call the oficial facebook App from my game instead open the safari browser. When the user click on my facebook button, I want to redirect him to my facebook page using the facebook oficial app.
I could using this:
Application.OpenURL ("fb://page/xxxxx");
The trick is to use fb:// instead http://www.facebook.com... So far, so good.
But what if the user does not have the facebook application installed?
So, I tried this one:
void OpenFacebookPage ()
{
WWW www = new WWW("fb://page/xxxxx");
StartCoroutine(WaitForRequest(www));
}
IEnumerator WaitForRequest(WWW www)
{
yield return www;
// check for errors
if (www.error == null)
{
Debug.Log("Sucess!: " + www.text);
}
else
{
Debug.Log("WWW Error: "+ www.error + " Opening Safari...");
//error. Open normal address
Application.OpenURL ("http://www.facebook.com/xxxxxx");
}
}
But it did not work as I expected - always return error. I guess it did not work because WWW not support the facebook protocol. In the Unity scripting reference:
Note: http://, https:// and file:// protocols are supported on iPhone. ftp:// protocol support is limited to anonymous downloads only. Other protocols are not supported.
So, I'm stucked here.. Anyone knows how to solve this?
Thank you!
Answer by cmsleal · Jul 13, 2012 at 11:55 PM
problem solved http://forum.unity3d.com/threads/143623-Open-facebook-app-instead-safari-iOS-C?p=982528&posted=1#post982528