Version 1.01 of my Social (Facebook) Unity Plugin for Android Released.

A new version of my Social Plugin for Android is now available. This fixes the screenshot bug (blank screen getting posted from an Android device), makes the logout revoke user permissions and adds a GenericRequest method that takes a ‘method’ parameter (that does make sense!).

A quick explanation:

Screenshots

Much confusion on this one, apparently ReadPixels had a functionality change at some point and now requires a ‘yield return null’ after it is called to give it time to do its thing. If you do this, it works perfectly, otherwise you get a blank screenshot. Note that Application.CaptureScreenshot didn’t seem to work at all on my Android devices so ReadPixels is definitely the way to go.

Logout

Again somewhat confusingly, logout using the current facebook sdk and SSO(Single Sign On) doesn’t really logout as such. See this link for a decent explanation and a sensibly confused user! You can set the ‘forcedialogauth’ flag to true in my plugin if you really want to force a user to log back in (as mentioned in the link). By revoking permissions on logout, it at least gets the user to reconfirm permissions when logging back in, if you don’t care about this, just comment out the RevokePermissions() line in the logout method.

If you have already purchased the plugin and wish to receive the new version send me an email with your original order details and I will send you the new version.

35 thoughts on “Version 1.01 of my Social (Facebook) Unity Plugin for Android Released.

    • Yes it does! SSO (single sign on) is a very handy feature and will be used by default if turned on when you set your app up in facebook.

        • Yes you can easily get the facebook user ID using a GenericRequest with a Graph Path of ‘me’. If you check out this youtube video, at 5m51s you can see a screen from one of the demos, this screen allows easy access to the Generic Request method, so in the Path box, if you type ‘me’, click on GenericRequest and you will get the facebook user ID back.

  1. Im using this plugin for a game , with the prime31 In-App Billing and i’m having some problem with the android manifest ( prime31 creates a new one ). Im at an impasse on how to merge the two xml. i would appreciate any help with this. Thanks.

    • Hi Lucian, yes merging manifests can be a bit tricky (hence my Android Bundle!) however here is a link to the various manifests in my bundle which may give you some pointers. Note that if the social plugin can’t be the main activity SSO won’t work (see FacebookUnityPlugin.cs for details ie set forcedialogauth = true).
      If you are still struggling, send me the manifests you are trying to merge and I will take a look.

    • Hi Matt, the social plugin supports the facebook Graph API which is pretty extensive see here. So adding links can be done in various ways but one way is to add a ‘link’ parameter, something like parameters = { \”link\” : \”http://www.platoevolved.com\”}, then use the GenericRequest method. It’s a bit too involved to stick in a comment however hopefully if you read the facebook documentation and experiment with my demo scene that has an example of sending parameters you should get there. I intend to do a Graph API tutorial with respect to my plugin soon, so subscribe to the website!

  2. Thanks for the reply, i did manage to merge the two manifests. Any ideas on how i can get the user access token without using graph api (the client wants to login using facebook app, and i can’t seem to get the user access token now, i used the graph to get the user’s friends , and the response also had the user access token)

  3. Hi, I purchased the plugin and its working. I can’t seem to generate a key hash to enable Facebook login.

    I even downloaded the Bluestack software and launched the app, clicked the login button as in the tutorial and no hash key appears.

    What am I missing? Any help would be greatly appreciated!

    • I should clarify that my main project has been developed on a mac. Bluestacks fails to load the .apk file on the mac.

      So, I went over to my pc to test all of this. Bluestacks was able to load the .apk and upon clicking the Login button, the Facebook page appears with no key hash.

      Now, I have assumed there is no key hash due to the fact that there is no key store info in that test project.

      But, this still leaves me with no idea as to how to obtain the key hash on a mac. All of the tuts online bring eclipse into the picture.

  4. Hello – I purchased your Social plugin for Android today, and got it all configured properly, got the screenshot uploads to work in the emulator just fine, but when I load to my actual phone, the screen shots post as all blue, or black backgrounds – no idea why it would work in the emulator and not the live phone. Please provide a way to contact you.

    Thanks,

    • Hi Aaron,

      Sorry you are having problems getting the screenshot upload to work. The problem is probably the PostPhoto() method and its use of ReadPixels. I had some issues with this a while ago but most people have been fine since I added the ‘yield return null’.

      ReadPixels is a notoriously finicky method that has been changed a few times by Unity (they obviously had some problems with it), there are still posts around that it doesn’t work on some devices still.

      (See this for some recentish changes)

      So one possible thing to try is to remove/move the ‘yield return null’, which should not be necessary if you are on Unity 3.5.5 or higher.

      Let me know if this does the trick, if not I will take a closer look.

      Kind Regards,

      Morgan
      (support@platoevolved.com)

  5. Got your plugin, and got a string to post. Now I am trying to get a photo to post and it post but only the post image is black. There is no yield null , if you have suggestions let me know. I have done research and seen one that stated that facebook does not like to post pngs, in newer builds. Please help.

    • Your the second person to have this problem so it looks like something must have changed either on facebook’s side or in Unity to stop the image posting working. I will take a look this weekend and hopefully get a fix out soon. Sorry for the inconvenience.

  6. HI!
    Got your plugin,but when I run SimpleDemo scene ,unity error log:

    JNI: Unable to find method id for ‘EnableLog’ (static)
    UnityEngine.AndroidJavaObject:CallStatic(String, Object[])
    FacebookUnityPlugin:EnableLog() (at Assets/Plugins/Demo/FacebookUnityPlugin.cs:78)
    SimpleDemo:Start() (at Assets/Plugins/Demo/SimpleDemo.cs:13)

    WHY?
    I am on Unity 4.0 ,what should I do?

  7. Hi, thanks for the plugin. Is there any way to use your PostPhoto() function to post a public Texture2D picture instead? I tried doing it and then reading the bytes[] and then posting them but it doesn’t work. Thanks!

    • I can’t see a problem in doing that as long as you EncodeToPNG the Texture2D (facebook expects a png). Let me know how you get on.

  8. Hi, this is probably the most noob question, but how can i properly call the init function via JS? I keep getting that my function overload is wrong.

    • Hi George,

      I would expect this to work fine:
      function Start () {
      FacebookUnityPlugin.Init(“Your app id”,[“publish_stream”,”manage_pages”,”publish_actions”]);
      }

      Let me know if it doesn’t! Also I just realised I didn’t help you out with the AndroidManifest file, sorry about that, I have posted a merged of Facebook/Admob manifest file here.

      • Thx, i really needed that manifest. Btw, there is a bug with unity 4.2, the orientation option from the build menu can’t override anymore the manifest option, so people may need to add android:screenOrientation=”landscape” to almost everything that would render something on screen. (Not reeeeally relevant i guess, i just thought to share it regarding the manifest.)

      • Say, is there a function to test if the player is successfully logged in facebook? to have the game behave differently if it is.

        • You can check for a valid session (whether user is logged in) with the following code, hope this helps you out:

          public static bool IsSessionValid(){
          if(started){
          AndroidJavaClass jc = new AndroidJavaClass(“com.platoevolved.socialpluginunity.FacebookUnityPlugin”);
          return jc.CallStatic(“IsSessionValid”);
          } else {
          return false;
          }
          }

          • Hi, yeah that seems to be what i was looking. When i paste it at the end of FacebookUnityPlugin.cs to be able to call it though, unity says that i cannot explicitly convert one type to the other. (Void to bool).

            So i changed it to
            public static void IsSessionValid(){
            if(started){
            AndroidJavaClass jc = new AndroidJavaClass(“com.platoevolved.socialpluginunity.FacebookUnityPlugin”);

            jc.CallStatic(“IsSessionValid”);
            }
            }

            Did i brake the universe yet? (thank for your continued support btw. I know i’m probably sidetracking you here.)

          • That’s the thing, it was bool, and unity’s debugger won’t accept it. I did change them back and forth, did some other changes, but unity didn’t like any of them.
            Mono shows it fine, unity doesn’t like it.

          • Sorry, always bad to try and write code away from a computer, here is some working code 😉

            public static bool IsSessionValid(){
            if(started){
            AndroidJavaClass jc = new AndroidJavaClass(“com.platoevolved.socialpluginunity.FacebookUnityPlugin”);
            return jc.CallStatic(“IsSessionValid”);
            } else {
            return false;
            }
            }

            I’ve just noticed the problem is wordpress is stripping out some code, you need open angle bracket bool close angle bracket after CallStatic (I will email you the code!)

          • Thx for the file, btw now that google has changed admob and the way they write the ads id, will we need to change something in the plugin other than the id line? will there need to be an sdk update?

Leave a Reply

Your email address will not be published. Required fields are marked *