Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

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

  1. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    I am having the same issue.

    But to be sure I do not misunderstood something :

    1- Does the URL Scheme is what you spoke about here?
    - http://www.youtube.com/watch?v=3-id13v0_L4

    Or that one from the Facebook app Basic info into the Native iOS App details?

    2 - Does bundle ID is the form starting by "com." ?

    Both question maybe looks weird but spend a lot of time today to sort out why I can't make it works...

    Twitter, GameCenter, flurry and Charboost plugins are working good so far!! ;)

    Thanks
     

    Attached Files:

    Last edited: Jun 6, 2012
  2. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @sama,

    1. that is correct. the URL scheme is setup with the tool from the Prime31 menu and should be the letters "fb" + your actual facebook app id
    2. the bundle ID scheme is up to you and is initially setup on Apple's website when you create your app. It is customary for it to be reverse domain name
     
  3. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    perfect it works!
    Thank you much!
     
  4. rmgalante

    rmgalante

    Joined:
    Nov 21, 2009
    Posts:
    59
    I have a problem in the Social Networking plugin with the FacebookBinding showDialog method.

    When I launch the dialog the first time, it closes immediately. It only happens the first time I load the dialog. The dialog simply closes. But every subsequent request works.
     
  5. byerdelen

    byerdelen

    Joined:
    Mar 27, 2010
    Posts:
    68
    Hi Prime,
    I have an interesting problem, I am using your Facebook plugin to take a screenshot and send it to Facebook on iPad. When it posts, it is posting the height around 640 such as iPhone4. And In iPhones, there is no problem at all. I have double checked the parameters and there is no problem on my screen dimensions. Can it be because Facebook has some limitations on the height of the posted images to Facebook?

    Thanks
     
  6. sinxtanx

    sinxtanx

    Joined:
    Feb 18, 2011
    Posts:
    25
    I have a problem with posting to a user's Facebook feed.

    Login is no problem, but whenever I try to post a message to the user's feed nothing happens.

    Everything is set up correctly according to the documentation, but no posts appear.

    Have tried both Facebook.instance.postMessage and implementing the graph request myself, none of them work.

    I have no idea why this would be the case, maybe someone here knows?

    Graph request has this format:

    Code (csharp):
    1. string message = "A message.";
    2.             var parameters = new Dictionary<string, object>
    3.             {
    4.                 { "message", message }
    5.             };
    6.             Facebook.instance.post("https://graph.facebook.com/me/feed?access_token="
    7. + FacebookBinding.getAccessToken(), parameters, (stringF, objectF) =>
    8.             {
    9.             });
     
  7. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @rmgalante, please open a bug report with Facebook. The dialog comes from
    Their web servers and we have no access to them to debug.


    @byerdelen, consult Facebooks documentation to see what their photo size limits are for mobile uploads. The plugin does not under any circumstance modify your photo. It merely passes it to Facebooks servers.


    @sinxtanx, your request is completely wrong. First of all you passed in a full URL instead of a graph path. You included a parameter in the URL as well (access token) which is not permitted. The access token is included automatically with all requests. Please review the examples in the Facebook class for how to properly make a graph request. There is a postMessage method that does exactly what you are trying to do.
     
  8. Fordeka

    Fordeka

    Joined:
    Aug 18, 2011
    Posts:
    78
    Hey Prime31,

    Do you know what causes a game to appear in a Facebook user's me/games connections?

    I've seen other games that use the Facebook API create an entry like this:

    {
    "data": [
    {
    "name": "GAME NAME HERE",
    "category": "Games/toys",
    "id": "ID HERE",
    "created_time": "TIME HERE"
    }
    ],
    "paging": {
    "next": "XXXXXX"
    }
    }
     
  9. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @fordeka, I haven't a clue what gets a game in that feed. It is quite possible only non-native apps can get in there but you will need to check Facebooks docs for the details.
     
  10. Fordeka

    Fordeka

    Joined:
    Aug 18, 2011
    Posts:
    78
  11. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @fordeka, the path should be nothing more than "me". Any additional parameters should be passed in via the parameters dictionary.
     
  12. sinxtanx

    sinxtanx

    Joined:
    Feb 18, 2011
    Posts:
    25
    Yes, that's what I did at first, and it didn't work then, and it doesn't work now either.
    Facebook.instance.postMessage does not work for me when the user is logged in. Nothing happens at all.
     
  13. Fordeka

    Fordeka

    Joined:
    Aug 18, 2011
    Posts:
    78
    Thanks, that worked. I was also wondering, should the PostprocessBuildPlayer script be running every single time I build (iOS)?
     
  14. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @sinxtanx, did you request the required permission when logging in? What is the error Facebook is returning?


    @fordeka, the script must run every build. It bails out early if it sees that the project is already setup.
     
  15. Fordeka

    Fordeka

    Joined:
    Aug 18, 2011
    Posts:
    78
    It seems to run about 5 minutes every build, could I be doing something that is preventing it from bailing out?
     
  16. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @fordeka, 5 minutes is way too long. We can put every plugin we have in one project and the first build still only takes 1 minute with subsequent builds being nearly instant. Go to the bottom of the General section of the docs and locate send over a log of a build so we can see what's happening.
     
  17. Fordeka

    Fordeka

    Joined:
    Aug 18, 2011
    Posts:
    78
  18. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @fordeka, it appears writing out the Xcode project file is the delay. I've never seen it take anywhere near that long. Have you run the Mac repair permissions tool recently? That is the only thing I can think of that would cause slow writes (besides a corrupt hard drive).
     
  19. Fordeka

    Fordeka

    Joined:
    Aug 18, 2011
    Posts:
    78
    No, but I'm building on a fairly low end Mac Mini. Can you suggest any alternative methods of building that do not involve writing a project file every time? It doesn't have to be production ready, I just need to test plugin related functionality.
     
  20. scott_dex

    scott_dex

    Joined:
    May 29, 2012
    Posts:
    8
    Just purchased both the iPhone and Android plugins. Thank you!

    Im not exactly sure how to search this topic for an answer, so apologies if this has been brought up.

    Im getting a crash when I try to call showPostMessageDialog(). The error is in the Prime31_MiniJSON_serialize section. I first init Facebook with the app ID and call login. That works no problem. I set up the app online and added the app id to the plist. Im wondering if there is something simple im forgetting.
     
  21. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @fordeka, after you do the initial build just rename the PostprocessBuildPlayer to any random name and the scripts won't run again until you rename it back.


    @scott, can you provide more information such as a stack trace from Xcode? Did you wait for the login successful event to fire before trying to show a dialog?
     
  22. scott_dex

    scott_dex

    Joined:
    May 29, 2012
    Posts:
    8
    Hey thanks for the reply. I made some progress by using showPostMessageDialogWithOptions and it seems to work :)
     
  23. Fordeka

    Fordeka

    Joined:
    Aug 18, 2011
    Posts:
    78
    That worked- it builds in 5-10 seconds now instead of minutes. Thanks again. :)
     
  24. YourUncleBob

    YourUncleBob

    Joined:
    Jun 11, 2012
    Posts:
    55
    I'm using the social plugin on both iOS and Android and running into a problem. With each device, I'm able to log in as one user (on my pad, I can log in as me, on a friends, I can log in as him, etc.). All authentication works, I'm able to make graph requests, etc.

    If on the same device I try to log into FaceBook as a different user, I always run into a screen that says "An error occurred. Please try again later". The FaceBook login was successful, behind the error screen I can see the wall of the new user. I am not brought to the screen allowing permissions for my title like I would be for successful logins. Returning to the game, the loginFailedEvent is called.

    I've tried this with both the FaceBook app installed and without. I've tried shutting down my game, logging into the FaceBook app as a different user, then starting the game back up again. I've made sure that the FaceBook app and safari are both logged out of FaceBook. I run into the same problem in all cases. I've checked and double checked my id's, setup the info.plist correctly, etc.

    Any clue what might be going on here?
     
  25. jfred1979

    jfred1979

    Joined:
    May 31, 2012
    Posts:
    6
    This page:
    http://prime31.com/unity/docs/ios/social.shtml
    Shows an overloaded version of showPostMessageDialogWithOptions that takes a hashtable with post options. I'm trying to allow the user to see the post dialog before posting an image to their wall, so postImage won't work. It looks as if there are options to attach an image to the post dialog, so the showPostMessageDialogWithOptions method looked like just what I needed. Was this from an older version of the plugin? If so, is there a different way to do what I want? Thanks!
     
  26. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @youruncle, the login is 100% handled on Facebooks servers or in their app. You will need to open a bug report with them to get an answer as to what is happening.


    @jfred, Facebooks dialogs do not and have never allowed attaching an image. You can send a url to an image but not the raw image data.
     
  27. jfred1979

    jfred1979

    Joined:
    May 31, 2012
    Posts:
    6
    @prime: that's the definitive answer I needed, I'll have to take a different route. Thanks!
     
  28. YourUncleBob

    YourUncleBob

    Joined:
    Jun 11, 2012
    Posts:
    55
    Yeah, I didn't figure there was a problem in the plugin, but I was hoping the behavior would ring a bell with someone. From where I sit, I'm poking at a big black box without a lot of clues to tell me why it's failing. I assume I set something up wrong somewhere, but all the pieces look correct, and it works for certain users on certain systems.
     
  29. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @youruncle, there is only 1 trick at all that most likely wont help but you never know. Open the FacebookManager.mm file and locate the handleOpenURL: method (around line 54). Add the following line to it then watch the logs when you do a login cycle on the device:

    Code (csharp):
    1. NSLog( @"url used to open app: %@", url );
     
  30. Basurman

    Basurman

    Joined:
    Sep 1, 2010
    Posts:
    10
    In my app the "Cancel, and return to app" link in the Twitter log-in window (see image attached) does not function correctly. It loads the URL specified as the callback URL for the Twitter app in the login window above my iOS app. I want it just to close the Twitter login window and return to app. How can I do this?

     
  31. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @basurman, what is the full URL that you are using as a callback URL?
     
  32. Basurman

    Basurman

    Joined:
    Sep 1, 2010
    Posts:
    10
    http://www.google.com, according to the Social Networking plugin documentation:

     
  33. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @basurman, we will look into this later today.
     
  34. Basurman

    Basurman

    Joined:
    Sep 1, 2010
    Posts:
    10
    Great thanks, looking forward to your reply.
     
  35. YourUncleBob

    YourUncleBob

    Joined:
    Jun 11, 2012
    Posts:
    55
    That's got me looking in the right area at any rate. Thanks. The URL that comes back is correct. When I log in as someone else, the Xcode output shows an error of "Invalid application ID. The Application ID is invalid." When I log in as myself, I see in the output a valid access token. It's passing the same application ID either way, and it looks to be correct.

    Does the URL it's calling in _facebook handleOpenURL look reasonable to you?

    fbauth2://authorize?type=user_agent&scope=publish_stream%2Cuser_about_me&client_id=XXXXXXXX&local_client_id=&redirect_uri=fbconnect%3A%2F%2Fsuccess&sdk=ios&display=touch

    The client id X's are our correct application ID. local_client_id is blank.
     
  36. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @youruncle, it looks fine but to be clear we haven't dig through the entire FB auth process so what each parameter means could be anything.
     
  37. YourUncleBob

    YourUncleBob

    Joined:
    Jun 11, 2012
    Posts:
    55
    OK, thanks. I'll dig into it some more.
     
  38. YourUncleBob

    YourUncleBob

    Joined:
    Jun 11, 2012
    Posts:
    55
    Found it. On the FaceBook app configuration page I had set our app to Sandbox mode when working with the web app version of the game a couple of days ago. Apparently that affects the iOS/Android versions as well. I thought it was a web app only setting. All my fault, but it would be nice of FaceBook to use an error message a bit more descriptive than "An error occurred. Please try again later" for this.
     
  39. Basurman

    Basurman

    Joined:
    Sep 1, 2010
    Posts:
    10
  40. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @basurman, are you using the latest version of the plugin? It works fine on our test devices.
     
  41. Basurman

    Basurman

    Joined:
    Sep 1, 2010
    Posts:
    10
    Just downloaded and installed the latest SocialNetworking_2012-06-12 package. Still experience the issue. Tapping "Cancel, and return to app" link results in just opening my Twitter app callback URL in this window instead of closing it and return to app.
     
  42. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @basurman, did you delete the old files before reimporting? We cannot reproduce when importing into a fresh project.
     
  43. beeky

    beeky

    Joined:
    Apr 6, 2009
    Posts:
    25
    I have a problem with posting a score to facebook.

    giving me this problem;

    InvalidCastException: Cannot cast from source type to destination type.
    at Facebook+<postScore>c__AnonStorey9.<>m__2 (System.String error, System.Object obj) [0x00000] in <filename unknown>:0
    at Prime31.P31RestKit.processResponse (UnityEngine.WWW www, System.Action`2 onComplete) [0x00000] in <filename unknown>:0
    at Prime31.P31RestKit+<send>c__Iterator0.MoveNext () [0x00000] in <filename unknown>:0

    (Filename: Line: -1)

    Is there a way how I can figure out whats going on in this dll file?

    I'm able to login, fetch my id, I receive an app id and can receive my friends ids.
     
  44. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @beeky, what are you passing the method? Is your app properly setup on Facebook as a game? Have you tried the demo scene which has a working version of posting scores? Invalid cast exceptions are almost always due to passing invalid types.
     
  45. beeky

    beeky

    Joined:
    Apr 6, 2009
    Posts:
    25
    I'm passing my facebook id and score,

    I have this exception on line 209 in Facebook.cs:
    var result = (bool)obj;
    completionHandler( result );

    I have the same issue with the example.
    'Get Scores' is working, post score not at the moment.

    app access token retrieved: 411318234448906292|etnSTUAoF9BDt3YTVJf25inOmwM
    UnityEngine.Debug:Internal_Log(Int32, String, Object)
    UnityEngine.Debug:Log(Object)
    SocialNetworkingGUIManagerTwo:<OnGUI>m__7(String) (at /Users/s/FF/src/Assets/Plugins/SocialNetworking/testSupportIOS/SocialNetworkingGUIManagerTwo.cs:134)
    <getAppAccessToken>c__AnonStorey8:<>m__1(String, Object) (at /Users/s/FF/src/Assets/Plugins/SocialNetworking/FacebookCommon/Facebook.cs:170)
    Prime31.P31RestKit:processResponse(WWW, Action`2)
    Prime31.<send>c__Iterator0:MoveNext()

    (Filename: /Users/s/FF/src/Assets/Plugins/SocialNetworking/testSupportIOS/SocialNetworkingGUIManagerTwo.cs Line: 134)

    InvalidCastException: Cannot cast from source type to destination type.
    at Facebook+<postScore>c__AnonStorey9.<>m__2 (System.String error, System.Object obj) [0x00006] in /Users/s/FF/src/Assets/Plugins/SocialNetworking/FacebookCommon/Facebook.cs:209
    at Prime31.P31RestKit.processResponse (UnityEngine.WWW www, System.Action`2 onComplete) [0x00000] in <filename unknown>:0
    at Prime31.P31RestKit+<send>c__Iterator0.MoveNext () [0x00000] in <filename unknown>:0

    (Filename: /Users/s/FF/src/Assets/Plugins/SocialNetworking/FacebookCommon/Facebook.cs Line: 209)
     
  46. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @beeky, you didn't anser all the questions I asked. Is you app properly setup on Facebook as a game? You can turn on debugging by setting the "debugRequests" to true in the Facebook class. Are you requesting the appropriate permissions as well to be able to post scores on behalf of a user?
     
  47. beeky

    beeky

    Joined:
    Apr 6, 2009
    Posts:
    25
    After some debugging and testing I found my problem.
    Facebook was returning an error message what gave the cast exception.
    last week I filled in some permissions and the auth token parameter option was set to query string by default.
    by turning of this Authenticated Referrals setting in Auth dialog on the Facebook developer page the warning left;
     
  48. Basurman

    Basurman

    Joined:
    Sep 1, 2010
    Posts:
    10
    Completely removed the old files and installed the latest version. Unfortunately it didn't help. I suspect that may be something wrong in my Twitter app settings but can't even guess what could it be.

    Any ideas?
     
  49. Basurman

    Basurman

    Joined:
    Sep 1, 2010
    Posts:
    10
    To localize the problem I created an empty Unity project and imported only latest Social Networking package (SocialNetworking_2012-06-12.unitypackage) to it. Then I added my test Twitter app consumer key and secret to TwitterBinding.init function in SocialNetworkingGUIManager. Then, I run your SocialNetworkingtestScene on iPad, tap "Initialize", then "Login with Oauth", the Twitter login dialog opens. Then I tap "Cancel, and return to app" link and observe the problem I described above (my app callback URL is loaded in dialog above my app, instead of closing this dialog and returning to app).

    Can you please have a look at this simple test project and tell me what I'm doing wrong?

    EDIT - PLEASE DON"T POST LINKS TO PROJECTS THAT CONTAIN SOURCE CODE TO COMMERCIAL PRODUCTS.

    Thanks in advance.
     
    Last edited by a moderator: Jun 20, 2012
  50. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @basurman, your Twitter app setup shouldnt affect that. We cannot reproduce what you are seeing. In addition, please remove the download immediately. Our EULA strictly forbids distribution of the source code of our plugins.