I’m using Facebook’s official plugin for Unity, but it only works in Facebook Canvas or in the Editor. When running in a browser that is not in Facebook Canvas, it does not work. I’d like to be able to detect whether it is running in Facebook Canvas or not. The app depends on Facebook for a lot of things, but I’d like it to still be able to run outside of Facebook Canvas for test purposes.
I first looked into adding an initFailure callback to the plugin, but it appears the methods under the hood that the plugin calls don’t return failures back to Unity. I’d like to avoid dealing with a timeout or something like that.
I also messed around with Application.absoluteUrl, but that only references the domain that is hosting the unity3d file, not whether it’s running in Facebook Canvas or not.
Just in case anyone else needs to do this, I ended up using ExternalEval to get some information I needed. I’m not fully happy with this implementation, but it’s the cleanest way I can find without waiting for an arbitrary amount of time from the Facebook plugin.