我们正在使用Facebook SDK for Unity (v6.0),我想知道是否有一种方法可以检查设备上是否安装了Facebook应用程序。
原因是Facebook SDK中存在一个已知的错误(请参见此处:错误)
我想识别这种情况(仅在安装了FB应用程序时发生),并做出相应的反应。
原因是Facebook SDK中存在一个已知的错误(请参见此处:错误)
我想识别这种情况(仅在安装了FB应用程序时发生),并做出相应的反应。
(void) checkFacebookApp
{
if ([[UIApplication sharedApplication] canOpenURL:[NSURLURLWithString:@"fb://"]])
{
return true;
}
}
然而,您需要在Unity和Xcode项目之间进行一些通信。因此;
class SomeScript : MonoBehaviour {
#if UNITY_IPHONE || UNITY_XBOX360
// On iOS and Xbox 360 plugins are statically linked into
// the executable, so we have to use __Internal as the
// library name.
[DllImport ("__Internal")]
#else
// Other platforms load plugins dynamically, so pass the name
// of the plugin's dynamic library.
[DllImport ("PluginName")]
#endif
private static extern float checkFacebookApp ();
void Awake () {
// Calls the FooPluginFunction inside the plugin
// And prints 5 to the console
bool check = checkFacebookApp ();
}
}