Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

Unity Like Facebook Page through app

$
0
0
Hi Unitarians, I have an android app, and I have a button that I want my users to click to go to my facebook page and like it. If I use `Application.OpenURL("https://www.facebook.com/youthquality");`, then it goes through the browser, which isn't ideal. I want it so that so it goes to the facebook app, if it is on the phone. I use the following code that works mostly: void Facebook () { #if UNITY_EDITOR Application.OpenURL("https://www.facebook.com/xxx"); #elif UNITY_IPHONE Debug.Log("Unity iPhone"); #else if(checkPackageAppIsPresent("com.facebook.katana")) { Application.OpenURL("fb://profile/xxx"); //there is Facebook app installed so let's use it } else { Application.OpenURL("https://www.facebook.com/xxx"); // no Facebook app - use built-in web browser } #endif } private bool checkPackageAppIsPresent(string package) { AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject ca = up.GetStatic("currentActivity"); AndroidJavaObject packageManager = ca.Call("getPackageManager"); //take the list of all packages on the device AndroidJavaObject appList = packageManager.Call("getInstalledPackages",0); int num = appList.Call("size"); for(int i = 0; i < num; i++) { AndroidJavaObject appInfo = appList.Call("get", i); string packageNew = appInfo.Get("packageName"); if(packageNew.CompareTo(package) == 0) { return true; } } return false; } The problem with the code is that it opens the facebook app, but it goes tot he newsfeed, and not to my page. How would I make it go to my page? My actual page has a set name that I put, not numbers. It is not a profile, it is a page.

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>