Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

[Closed] Social Networking Plugin (Facebook and Twitter) live!

Discussion in 'iOS and tvOS' started by prime31, Sep 19, 2010.

  1. AntLewis

    AntLewis

    Joined:
    Feb 2, 2010
    Posts:
    239
    Hey prime31 - quick question, I've just purchased your social network plug in for iOS. The FacebookTestScene only seems to work when I build to an iOS device. Obviously that's my final target, but wondered if it should still work from the desktop?

    Possibly a stupid question ;-)

    Cheers
     
  2. xikky

    xikky

    Joined:
    Dec 11, 2012
    Posts:
    47
    Hi Prime,

    I'm experiencing a problem with the plugin since the last update. I updated the plugin from Unity Prime31 menu/Update prime 31 tools. The GET methods are not functioning anymore. I am sure that the problem is caused from an update because I went back to a previous version (separate unity project), built the game and everything worked. Then I updated the same project and it stopped working.

    The problem is occurring when I'm trying to read the value from the hash received. The request is received successfully, but execution stops immediately when I try to access the hash, example:

    Code (csharp):
    1. appID = hash["id"].ToString();
    execution stops at this line. (Or any other line which uses the hash).

    This is how I'm sending the graph request:

    Code (csharp):
    1. public void GetAppID () {
    2.        
    3.         checkGetAppID = true;
    4.  
    5.         Dictionary<string,string> Hash = new Dictionary<string,string>();
    6.         Hash.Add("access_token", FacebookAndroid.getAccessToken().ToString());
    7.         Hash.Add("fields", "id");
    8.         FacebookAndroid.graphRequest("/app", "GET", Hash);
    9. }
    This is how I'm receiving the message:

    Code (csharp):
    1. void graphRequestCompletedEvent (object obj) {
    2.        
    3.         if (checkGetAppID) {
    4.            
    5.             checkGetAppID = false;
    6.  
    7.             //returns app ID.
    8.             Hashtable hash = obj as Hashtable;
    9.             appID = hash["id"].ToString(); //execution stops on this line!!
    10. }
    Please help me with this problem. Thank you.

    --------------------------------------------------------------------------------------------------------------------------------------------------

    Found this on your website in the updates section:

    But the link to post only takes me to http://prime31.com/. Where should I enable Json.useSimpleJson?
     
    Last edited: Aug 6, 2013
  3. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @xikky, you can add the line "Json.useSimpleJson = true" anywhere in your project before you start using the Facebook class. It doesnt matter where.
     
  4. xikky

    xikky

    Joined:
    Dec 11, 2012
    Posts:
    47
    Ok, thanks. But where do I find the Json class? I'm having this error: The name `Json' does not exist in the current context.
     
  5. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @xikky, it is in the Prime31 namespace
     
  6. xikky

    xikky

    Joined:
    Dec 11, 2012
    Posts:
    47
    Thanks Prime. I only use C# for this facebook plugin and wasn't aware of that. Unfortunately the problem is still occurring. I placed the Json boolean in awake function, in a class which takes care of my facebook methods in my project. Any ideas?

    I'm using Unity 4.1.5 and testing on Android 4.1.2
     
    Last edited: Aug 6, 2013
  7. Byrondinho

    Byrondinho

    Joined:
    Jul 26, 2011
    Posts:
    19
    Hi Prime31,
    Like others users of this forum, i have this issue in my iPhone4.

    I have facebook running in background and when i run my app and launch a login with permissions happens the error. If i try again didn't happens.
     
  8. xikky

    xikky

    Joined:
    Dec 11, 2012
    Posts:
    47
    Hi Prime31,

    I am still experiencing problems with the new update. I can Login to facebook and send POST requests but I cannot receive a GET requests successfully. The dictionary seems empty.

    I have avoided this problem by restoring social networking android version to an older one which used to work. But today I bought the iPhone version of social networking and it seems I have to update both plugins to the latest version for them to work properly together.

    I have removed all files and folders and imported a fresh copy of iPhone and Android social networking. Included the app ID in manifest file and generated a new AndroidManifest file. I also included Json.useSimpleJson = true; in the Awake() function in a class which is similar to the demo's FacebookUIManager.

    The problem is still persisting. Is there a solution for this issue? And if yes, what should I do to fix this?

    Please help .. I'm lost and don't know what to do more...

    p.s. I am currently testing on Android 4.1.2
     
    Last edited: Aug 14, 2013
  9. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @xikky, we can't reproduce what you are seeing with the demo scene. Feel free to send over a proper bug report including all steps to reproduce, full log output, devices tested on, OS version and the repro project itself.
     
  10. xikky

    xikky

    Joined:
    Dec 11, 2012
    Posts:
    47
    Where can I send you a repro project? Thanks you.
     
  11. sunkas85

    sunkas85

    Joined:
    Aug 16, 2012
    Posts:
    14
    Hi

    My isSessionValid() always returns false. Tried to run init() before calling isSessionValid() but then the facebook login dialog always showed, even if I was logged in.

    Any ideas of how to solve this?

    Code (csharp):
    1.      if (FacebookAccess.isSessionValid())
    2.         {
    3.             Debug.Log ("Session is valid");
    4.             LoginToFacebook();
    5.         }
    6.         else
    7.         {
    8.             Debug.Log ("Session is not valid. Show button for login...");
    9.             ShowLoginButton();
    10.         }
    11.     }
    Where LoginToFacebook calls FacebookAccess.init() and then FacebookAccess.loginWithReadPermissions (permissions);
     
  12. Nox Noctis

    Nox Noctis

    Joined:
    Feb 11, 2013
    Posts:
    5
    Hi,

    I've got a problem using latest combo version of Prime31 social plugin.
    I build the bundled test scene and launch it on an iPad with iOS 6.1.3.
    I press two buttons -- "initialize facebook" and "login" -- but nothing seems to happen.
    What am I possibly doing wrong?
    Thanks for any tips.
     
    Last edited: Aug 23, 2013
  13. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @nox, are you listening to all the appropriate events? I find it hard to believe that not a single event fires during an authentication. If you test with the demo scene all events are automatically logged for you.
     
  14. Nox Noctis

    Nox Noctis

    Joined:
    Feb 11, 2013
    Posts:
    5
    @prime31 Which is exactly why I'm really puzzled. I'm testing your scene with no alterations made. You have a FacebookEventListener instance there that should report at least something. Alas, I get nothing in console. Before I have updated my project to combo version of your plugins I used FacebookBinding, and it worked fine. Now I don't even see the usual facebook login behaviour like a page popping up etc.
     
  15. Nox Noctis

    Nox Noctis

    Joined:
    Feb 11, 2013
    Posts:
    5
    @prime31 May be you could suggest some experiments I can perform to diagnose the malfunctioning? I'm really starting to think about writing the whole stuff myself. (( Which is boring and annoying (been there, done that for another platform), so I'm eagerly paying for your plugin. I need an update to my product shipped in next 3 business days. The impending doom, you know.
     
  16. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @nox, if things worked when using the FacebookBinding class than I would suggest going back to using that. Additionally, the standard fare of adding logging and using the debugger is usually a good idea.
     
  17. Gamemiracle-GM

    Gamemiracle-GM

    Joined:
    Aug 9, 2013
    Posts:
    12
    Hi

    sry my english.

    i found out problem. i upgraded newest version prime31 social networking for iOS

    ---> get me id, name
    Facebook.instance.graphRequest("me?fields=id,name", completionHandler);

    --> completionHandler(error, obj)
    ResultLogger.logObject( obj );

    Error message : obj is not a hashtable or arraylist

    Debug.Log(obj);
    System.Collections.Generic.Dictionary`2[System.String,System.Object]

    It is ok before upgrade new plugins
     
  18. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @GM, non-generic collections were deprecated over a year ago. Use IDictionary or IList
     
  19. Gamemiracle-GM

    Gamemiracle-GM

    Joined:
    Aug 9, 2013
    Posts:
    12
    @prime31, thank you,

    get facebook ID is work.
    var ht = result as IDictionary;
    var usrid = ht["id"].ToString();
    var usrname = ht["name"].ToString();

    can you help me how to getFriends ?
    return value lList<lDictionary> ?
    do you have any sample code ?
     
  20. Nox Noctis

    Nox Noctis

    Joined:
    Feb 11, 2013
    Posts:
    5
    @prime31 Yeah, nice solution, thank you. I still can't get your test scene working. I have uncommented Facebook.instance.debugRequests = true; and placed logs in every method that gets called when I press init and login buttons. Here's what I get in the output:
    It does not seem to get me anywhere.
    Tried deleting the social plugin from the project and importing it back. Still no clues.

    The Twitter scene does at least something: login form pops up. The Facebook scene is not functioning at all.
    So, it appears to me, that I will have to use old version of plugin. :(
     
  21. sunkas85

    sunkas85

    Joined:
    Aug 16, 2012
    Posts:
    14
    @Prime31 did you read my question?

    Best Regards
    Jonas Andersson
     
  22. CinLing

    CinLing

    Joined:
    Jul 15, 2013
    Posts:
    6
    var ht = result as IDictionary;
    var ListFriend = ht["data"] as IList;
    for (int a = 0; a < ListFriend.Count; a++)
    {
    //friendName += "ID[" + a + "] = " + ListFriend.ToString() + "\n";
    var DictList = ListFriend[a] as IDictionary;
    if (DictList != null)
    {
    friendName += "ID[" + a + "] = " + DictList["id"].ToString() + "\n";
    }
    }

    This my code
     
    Last edited: Aug 27, 2013
  23. vitaly

    vitaly

    Joined:
    Oct 12, 2012
    Posts:
    10
    Is it possible to fetch image profile without being authenticated to facebook, using social networking plugin for android?
     
  24. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @vitaly, fetching profile images only requires the user ID. No authentication is necessary
     
  25. Nox Noctis

    Nox Noctis

    Joined:
    Feb 11, 2013
    Posts:
    5
    @prime31 Somehow the changes made to info.plist got abandoned which is why nothing was working. Ok, I was stupid, I admit it. )) But at least you could point me to the right direction. And your plugin MUST report the fact that a user has not set up the app correctly.
     
    Last edited: Aug 30, 2013
  26. stats007

    stats007

    Joined:
    Aug 28, 2013
    Posts:
    1
    @prime31

    Hi,

    I've been using your plugin and wanted to confirm the behaviour of Facebook.instance.postScore as I'm not seeing any result despite the API call allegedly succeeding. Your docs prototype the function here as:

    // Posts a score for your app
    public void postScore( string userId, int score, Action<bool> completionHandler )


    however in Facebook.cs it's defined as:

    // Posts a score for the current user
    public void postScore( int score, Action<bool> completionHandler )
    {
    // post the score to the proper path
    var parameters = new Dictionary<string,object>()
    {
    { "score", score.ToString() }
    };

    post( "me/scores", parameters, ( error, obj ) =>
    {
    if( error == null obj is string )
    {
    completionHandler( ((string)obj).ToLower() == "true" );
    }
    else
    {
    completionHandler( false );
    }
    });
    }


    Reading through this thread it appears that supplying the app token and user ID has been superceeded - is this the case? For reference I can post messages etc to the user's wall without issue.

    Thanks,

    Andrew
     
  27. vitaly

    vitaly

    Joined:
    Oct 12, 2012
    Posts:
    10
    In my application, the facebook dialog pops up every time i enter the app. And every time a read "you have already authorized APPNAME".
    Everything works without and with facebook application installed. But I don't want my users to enter my login and password every time.
    What i do is.
    I call FacebookAndroid.Init()
    And check if FacebookAndroid.isSessionValid()
     
  28. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    @Prime31

    I noticed that when the game fails to reload after connecting to Facebook via fast-app switching my game then fails to launch until I do a full rebuild of it.

    I did a quick hack fix in FacebookManager.mm to fix it

    + (NSString*)JSONStringFromObject:(NSObject*)object
    {
    NSError *error = nil;

    + // My hack
    + if(!object)
    + return @"{}";
    +
    ....

    But it seems like that code has been moved into the P31 library now so I can't do it anymore unless I hack more code. (NSObject*)object is nil so [NSJSONSerialization dataWithJSONObject:eek:bject is throwing an exception.

    Is this fixed in the latest version of the SDK?

    Cheers
     
  29. Russel

    Russel

    Joined:
    Oct 12, 2011
    Posts:
    40
    I have problems after Update to Android Social Networking v3.0.

    sessionOpenedEvent () is called before the confirmation of the Permission! Why?
    Did I forget anything with the update?

    The "Class Name" should always be setup as "com.prime31.UnityPlayerProxyActivity"? Where is this Activity in the Android-Manifest? Previously it was: com.prime31.FacebookProxyActivity

    Here is my question in in prime31 support page:
    http://prime31.com/support/5087/problems-after-update-to-android-social-networking-v3-0

    Thank you for your help!
     
  30. PrwC

    PrwC

    Joined:
    Sep 3, 2013
    Posts:
    1
    @brianasu,@prime31

    I found this problem too after update new plugins about JSON is null. below this is show on my xcode log

    but this affect only on iOS 5.1 above that (iOS 6+) run clearly, I don't know why this happen :confused:
     
  31. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    @PrwC
    Yeah iOS 6+ is fine since it can use native logins. Although, some people choose to not use that and the app falls back to fast-craap-switching.

    @Prime31
    I'll try to reproduce and check where in the stacktrace and what variables are nil if needed.
     
  32. StevenSauer

    StevenSauer

    Joined:
    Mar 25, 2013
    Posts:
    19
    Hey prime31

    I'm running into an issue with Android where certain xml files are being overwritten by your plugin (strings.xml, styles.xml, and main.xml) that were originally placed by the Unity OBB Downloader. I have found a very lame fix by just manually merging the two, but I'm also noticing that the same happens with I'm not using the OBB Downloader and only using prime31 plugins. Example: Social Networking Game Services. Both use strings.xml but both just overwrite rather than merge. Am I doing something wrong or do I literally have to manually merge them every time I update, add, or change a plugin?

    Thanks
     
  33. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @steven, manually merging shared resources is the only solution on Android.
     
  34. Gonemad

    Gonemad

    Joined:
    Mar 20, 2013
    Posts:
    15
    I'm using the Social Networking plugin for Android and am running into double-login screens for Facebook. On my app login screen, I request read permission so I used the loginWithReadPermissions() method, which brings up the FB login web page and the whole OAuth takes place. So far so good.

    Subsequently, on a post, I request publish permission by calling reauthorizeWithPublishPermissions() method, which again brings up the FB login page. Is there a way to suppress the FB login page the second time around and only present the page asking the user for the "post" permission? Asking the user to re-login into FB for publish permission makes the app seem broken... Thanks in advance for any workaround you can provide.
     
  35. PaulJ

    PaulJ

    Joined:
    Sep 7, 2012
    Posts:
    4
    Hello. I'm using SharingBinding.shareItems with jpegs and they are coming out black. It works perfectly with PNGs and I can see the jpeg on the disk and it looks normal. Any thoughts?


     
    Last edited: Sep 14, 2013
  36. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @paul, the plugin just sends the file along so your best bet is to figure out what Apple doesn't like about your JPEG encoder or just use PNGs
     
  37. Gonemad

    Gonemad

    Joined:
    Mar 20, 2013
    Posts:
    15
    Hi Prime,

    Are there compatibility issues in using the Etcetera plugin on Android OS v2.3.3? We've seen a "forced close" in our test lab after the user clicks the button to rate our app. Here's what we were able to capture on the console:

    09-17 09:40:30.510: E/AndroidRuntime(23046): at com.prime31.EtceteraPlugin$23$1.onClick(EtceteraPlugin.java:1077)
     
  38. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Gonemad, please post Android questions in the Android forum.
     
  39. amit.r007

    amit.r007

    Joined:
    Jun 1, 2013
    Posts:
    17
    Hi Prime,

    I had purchased the Social Networking plugin for android.

    I am able to login to facebook using the plugin code.

    Now I need to fetch my data. i.e my name and other details.

    I know It is done using
    but my issue is how to get my details from "me" ( my name, id, profile image etc.)

    I am using C#.

    I have tested the demo scene but its a log generated directly. I need the code to extract my data :)

    Regards,
    Amit
     
  40. davidhorak

    davidhorak

    Joined:
    Nov 7, 2012
    Posts:
    16
    C# Solution:
    Code (csharp):
    1. private void FacebookGraphRequestCompletedEvent(string error, object result){
    2.      
    3.      // Create Hashtable from  IDictionary
    4.      Hashtable ht = new Hashtable(result as IDictionary);
    5.                
    6.      // Get values by keys
    7.      var someValue = ht["someKey"];
    8. }
     
  41. serioustommy

    serioustommy

    Joined:
    Jun 12, 2012
    Posts:
    126
    Hi Prime,

    I'm using the latest facebook plugin (though not sure if this is a new issue or not).

    The problem is that when reauthorizing using the facebook app switching login, if you disallow by clicking "skip" then upon switching back to your app you'll get the sessionOpenedEvent + reauthorizationSucceededEvent instead of the fail one.

    The fail callback works fine when reauthorizing with the iOS built-in popup.

    Also is it intentional that sessionOpenedEvent always fire with reauthorizationSucceededEvent when reauthorizing?
     
  42. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @serious, the sessionOpenedEvent if fired every time Facebook sends it to the plugin. There is no rule that it cannot be opened more than once. Since you didnt provide even a single logs at all and we cant reproduce what you are seeing there isn't much I can suggest.
     
  43. serioustommy

    serioustommy

    Joined:
    Jun 12, 2012
    Posts:
    126
    ok sorry I thought what I was asking was obvious. here's the code:

    FacebookBinding.reauthorizeWithPublishPermissions("publish_actions", FacebookSessionDefaultAudience.Friends);

    Then in the Facebook App that opens, click "skip" to disallow.

    After the app switches back, FacebookManager.reauthorizationSucceededEvent is called. However FacebookManager.reauthorizationFailedEvent was expected.

    Note that this doesn't happen if the built-in iOS permission dialog is used instead and FacebookManager.reauthorizationFailedEvent is properly fired when disallowing.
     
  44. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @serious, I guess you missed my previous replay. How about providing some logs? The plugin logs extensively the auth and reauth process. Without some actual information to work with there is nothing we can do for you.
     
  45. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
  46. Atiko7

    Atiko7

    Joined:
    Nov 26, 2012
    Posts:
    3
    Hi guys!

    I'm having trouble posting an image to FB, I'm using the etcetera plugin, specifically the function Facebook.instance.postImage(bytes, "Title", completionHandler)... but in xcode I'm getting Error 400 bad request.

    I've use this before and didn't have any problems... I'm using Unity 3.5 and the latest version of the plugin.

    Any idea what could be wrong?

    Thanks!

    Also.. I'm using the latest version of Xcode, and testing on an iPhone 4 with iOS 7
     
    Last edited: Sep 27, 2013
  47. blacksp1der

    blacksp1der

    Joined:
    Dec 11, 2007
    Posts:
    76
    @Prime31, please update the plugin for asset store users.
     
  48. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @blacksp1der, the update was submitted many days ago.
     
  49. LordRyuuza

    LordRyuuza

    Joined:
    Aug 17, 2012
    Posts:
    5
    Hello @Prime31, I'm using the latest Social Networking Plugin, however when I updated to this version I get the following log "the object that is being serialized [(null)] is not a valid JSON object. This error is thrown when I try to fetch the facebook image.
    Also, when I try to request the authorization to post I get that the permissions are null or have zero elements on list. I'm posting the following code to show it.

    Code (csharp):
    1.     List<object> permissions = FacebookBinding.getSessionPermissions();
    2.  
    3.                 #if DEBUG_FACEBOOK
    4.                 System.Console.WriteLine("FACEBOOK reauthorizing...");
    5.                 #endif
    6.  
    7.                 if (permissions == null || permissions.Count == 0)
    8.                 {
    9.                     #if DEBUG_FACEBOOK
    10.                     System.Console.WriteLine("FACEBOOK permissions are null or Zero");
    11.                     System.Console.WriteLine("FACEBOOK requesting needed permissions");
    12.                     #endif
    13.  
    14.                     var perm = new string[] { "publish_actions", "publish_stream" };
    15.                     FacebookBinding.reauthorizeWithPublishPermissions(perm, FacebookSessionDefaultAudience.Everyone);
    16.                 }
    17.  
    When this code is executed, the browser is opened and try to do something with facebook, but I get the following log messages

    -> applicationDidEnterBackground()
    -> applicationWillTerminate()


    I'm using Unity 3.5.7f6 and compiling for OS Target 6.0.

    Thanks.
     
  50. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @lord, you can't fetch an image with the graphRequest method. Images are raw data and the graphRequest method expects JSON. The plugin includes a methods to fetch images (fetchProfileImageForUserId or fetchImageAtUrl).

    applicationDidEnterBackground and applicationWillTerminate are completely normal logs. Just watch the logs when you run any Unity app on earth and they will appear.