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

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

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

  1. Artial

    Artial

    Joined:
    Dec 27, 2008
    Posts:
    22
    I already double checked everything, to no luck. Also, everything is working fine (score api, request, feed etc) with the app switching fallback which is why I don't know which setting could be wrong - otherwise some feature wouldn't work.
     
  2. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @artial, if you are certain that everything is properly setup you will need to shoot a bug report over to Facebook. Their SDK is what chooses native authentication vs fast app switching.
     
  3. Artial

    Artial

    Joined:
    Dec 27, 2008
    Posts:
    22
  4. jxxxxst

    jxxxxst

    Joined:
    Nov 3, 2012
    Posts:
    50
    Dear Prime31,

    I'm dealing with an annoying problem in my project,
    when using the login function or the reauthorizeWithPublishPermissions function my app restarts while switching back from the safari browser back to my application. This usually the case, when I'm registering the app for the first time (which is successful). After that I can let the app switch between itself and the web browser without any problems (although it tells me i have already registered the app -> So I hit okay). I still try to figure out what could be causing this, but right now it seems random to me. Any ideas what I should take into account?

    Best Regards
     
  5. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @hans, if you login or attempt to reauth Facebooks SDK will fast app switch to perform the task. Don't login or reauth if you do not need to and already have an access token.
     
  6. Idoli

    Idoli

    Joined:
    Nov 3, 2012
    Posts:
    1
    I updated to the latest version today and I've been running into issues with logging into facebook in my game, logging out, and then logging back in. If I just log in once and stay in, everything seems to be great. I only run into the issues when I log out, and then back in while in a single session.

    For both logins I am using:
    FacebookBinding.loginWithRequestedReadPermissions( new string[] {"email"});

    For the logout I am using:
    FacebookBinding.logout()

    The error I am getting is:
    2012-11-03 17:05:05.235 RedactedAppName url used to open app: fbRedacted#://authorize#code=RedactedCode&expires_in=5176082
    2012-11-03 17:05:05.258 RedactedAppName An instance 0x1f8ab1c0 of class FBSessionManualTokenCachingStrategy was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:
    <NSKeyValueObservationInfo 0x1f8ab690> (
    <NSKeyValueObservance 0x1f8ab300: Observer: 0x1f8ab3e0, Key path: accessToken, Options: <New: NO, Old: NO, Prior: YES> Context: 0x1461014, Property: 0x1d6366d0>
    <NSKeyValueObservance 0x1f8ab650: Observer: 0x1f8ab3e0, Key path: expirationDate, Options: <New: NO, Old: NO, Prior: YES> Context: 0x1461014, Property: 0x1d637e40>
    )
    -> applicationDidBecomeActive()
    SendMessage: object FacebookManager does not have receiver for function facebookLoginSucceeded!

    This second part seems to imply that the FacebookManager object is getting removed somehow, but I'm not quite sure how that would happen. I'm not sure what the first part is about exactly.

    Thanks for any help!
     
  7. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @idoli, the warnings about KVO are normal and part of the Facebook SDK. The actual problem is that you don't have the FacebookManager in your scene as is evidenced by the log: "SendMessage: object FacebookManager does not have receiver for function facebookLoginSucceeded!"
     
  8. jxxxxst

    jxxxxst

    Joined:
    Nov 3, 2012
    Posts:
    50
    Dear prime31,

    thanks for the quick reply. The fast App switching is fine, it is just the complete app restart or reset that happens (like if you would quit the app), when I get the read or publish permissions for the first time and switch back to the app. I still se the URL command in safari for a split second, but after that the App is restarted.
    I actually call the logout function when i start the app, reset my Ipod Settings and remove the app from my facebook account, whenever I run a test.
    So that I always simulate a fresh install.

    It is hard figure out whats wrong, since I don't get a debug log, once I switch over to safari.

    This happens, when I use

    FacebookBinding.loginWithRequestedReadPermissions(new string[] { "email" });
    or
    FacebookBinding.login();

    I'm on IOS 6.
    You mentioned the access token, how can I make sure I have a valid one, that doesn't confuse the app switching?

    Best Regards
     
  9. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @hans, the getAccessToken method gets the access token.
     
  10. jxxxxst

    jxxxxst

    Joined:
    Nov 3, 2012
    Posts:
    50
    Figured it out, turned out not to be related to the plugin at all,
    memory usage was too high, which resulted in a faulty fast app switching. App would get terminated while switching to the safari browser already.
    The xcode debugger would not show any crash information, but the device console from the organizer was more helpful to figure this out.

    Best Regards.

    Update: If anyone ever stumbles over this, this is my Info:
    On my Ipod Touch 4g the real memory usage (you can check this via Xcodes Activity Monitor Instrument)
    of 60-70 mb would cause the app to be terminated in the background quite often during the fast app switching.
    I'm now back to 40-50 real memory usage and everything seems to be working just fine.
     
    Last edited: Nov 6, 2012
  11. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,516
    Oops! Heading over there now.
     
  12. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    414
    I've got everything now working great with Facebook and Social Networking! I've come across one small problem, that I'm certain is me checking something wrong. I've found that if I run my game today and login to Facebook and post, all works fine. However, if I try again after about 24 hours, my application seems to think that I am still logged in to Facebook - however anything posted never gets to Facebook, and I'm unable to acquire any actual data.

    To check if I have to login or not, I'm simply testing against FacebookBinding.isSessionValid(). Is there more that I should be checking to ensure that the player is properly logged in with a valid session with all needed permissions? Or do I need to request read / write permissions every session?
     
  13. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @dcalabrese, Facebook recommends extending the access token via the Graph API every launch to ensure it is valid.
     
  14. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Hi Prime,

    is there a way to post to a friend's wall instead of my own? We are thinking that would be of more use to us currently....
     
  15. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @jerotas, visit Facebooks documentation to find out what can be done and what cannot. Facebooks Graph API is immense and the only way to find out what it can do is to dive into their docs.
     
  16. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Oh I am sure it can be done, I was just wanting to know if you had an easier way to do it than the graph. Guess not. Thanks!
     
  17. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @jerotas, the Graph or REST APIs are the only way to access Facebook. There are no magical shortcuts.
     
  18. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Well if you wanted to make this plugin even more valuable (you could charge more), you could wrap some of the graph API calls to make it even easier. I know there are tons and tons, but maybe just a few of the super useful ones. That's all I am saying. I have already done that myself on a few of these.
     
  19. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @jerotas, the entire Facebook class included with the plugin wraps the most common Graph API calls and acts as a template for any others required specific to your app. You can quite simply copy/paste any of the methods in there and change the parameters appropriately. Creating a Dictionary really isn't that hard and it is all that is required to call a Graph API method with the plugin. There isn't much more we can do to simplify it any more while still allowing full Graph API access.
     
  20. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    I beg to differ, having wrapped a couple myself and doing things with the data retrieved afterward to make it useful. Friend scores for instance.
    Not that it is hard, but there is a certain amount of testing that has to go into coding those things to make sure it is working, and you have to deploy to your target device to test it as well, which reaaaaally slows down the process. But if it were known good working tested code, well everyone would benefit. Actually I am now entertaining the thought of releasing my wrappers for this on the App Store myself sometime. Perhaps free, perhaps at a very minimal cost.
     
  21. Amarildo

    Amarildo

    Joined:
    Nov 6, 2012
    Posts:
    3
    Dear Prime31,
    please add an #if UNITY_IPHONE condition into FacebookBinding class in your next release!
    My project is cross-platform and I'm using several plugins. So every time I need to update a prime31 plugin I have to check and manually patch the code.
    Just to say, FacebookAndroid is ok for that.
    Thank you.
     
  22. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @amarildo, we have a split from our users: half like the *Binding classes wrapped and half do not. We havent found a way to please everyone yet so for now we will be leaving things as is. Your code should compile fine as long as you delete the "testSupport" folders which are just for the demo scenes.
     
  23. Amarildo

    Amarildo

    Joined:
    Nov 6, 2012
    Posts:
    3
    @prime31
    Actually it does not compile if I build for Web because FacebookManager is targeted to ios/android only.

    Anyway I've a more important issue... On iOS 6.0 with Facebook enabled in settings the login does not work after the last update of plugin. Every time I catch the error "FacebookService Unable to login : The operation couldn’t be completed. (com.facebook.sdk error 2.)".
    I triple checked almost everything:
    - completely removed plugin (every file) and reinstalled as new, with a clean quit&restart unity;
    - url schemes facebook app id are ok;
    - double flow authentication respected, just the read permissions are used for login;
    - removed the previous xcode project;
    - the facebook app is well configured, the official facebook sample app works.

    Any idea to fix it?
     
  24. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @amarildo, that particular error usually indicates improper app setup (URL scheme, bundle ID, etc) if I recall. You will want to check the Facebook docs to be certain though.
     
  25. DavidC02

    DavidC02

    Joined:
    Jul 19, 2011
    Posts:
    152
    Hello,

    I'm getting this error when I try to Build and Run:
    /Users/David/MyProject/Assets/Editor/SocialNetworking/FacebookSDK/libFacebookSDK.a(FBViewController.o)
    duplicate symbol _OBJC_METACLASS_$_FBViewController in:
    /Users/David/MyProject/Assets/Editor/SocialNetworking/FacebookSDK/libfacebook_ios_sdk.a(FBViewController.o)
    /Users/David/MyProject/Assets/Editor/SocialNetworking/FacebookSDK/libFacebookSDK.a(FBViewController.o)
    ld: 350 duplicate symbols for architecture armv7
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    I can't compile, on the left panel Xcode says Apple Mach-O Linker Error

    I should also mention that I get a warning
    /Users/David/MyProject/Assets/Editor/SocialNetworking/FacebookManager.mm:220:3: 'openActiveSessionWithPermissions:allowLoginUI:completionHandler:' is deprecated

    Do you have any suggestions? I really have no idea how to fix this one.
     
  26. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @david, duplicate symbols almost always mean that you didnt delete old plugin files before importing the latest. Remove your Editor/SocialNetworking folder and reimport the latest version of the plugin.
     
  27. DavidC02

    DavidC02

    Joined:
    Jul 19, 2011
    Posts:
    152
    Thanks for your quick reply, I now get the following:
    ld: library not found for -lFacebookSDK
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
     
  28. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @david, delete your Xcode project and rebuild it.
     
  29. DavidC02

    DavidC02

    Joined:
    Jul 19, 2011
    Posts:
    152
    I'll give it a shot tomorrow, I'm not at the office anymore, thanks for your reply.

    Edit: Worked great, thank you so much.
     
    Last edited: Nov 7, 2012
  30. ScsiOverdrive

    ScsiOverdrive

    Joined:
    Nov 7, 2012
    Posts:
    13
    Hello!

    I am trying to get the twitter oauth login dialog to show up in a different language (Portuguese).

    I have been searching this forum, the API docs, google, etc. and haven't found a way to do this.

    I am currently using "TwitterBinding.showOauthDialog();" but users in Brazil report the login is in english.

    I have attempted using TwitterBinding.performRequest() but am not having any luck with this either.

    Any ideas would be greatly appreciated, thanks! :)
     
    Last edited: Nov 7, 2012
  31. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @scsi, check with Twitter on that one. There is no API access to modify the language their web site is displayed in.
     
  32. ScsiOverdrive

    ScsiOverdrive

    Joined:
    Nov 7, 2012
    Posts:
    13
    Thank you for the quick reply!

    Is there any way to get the login dialog to show with performRequest(), or is that not what its intended for?

    I will start doing more research on the twitter side of things.

    Thanks again!
     
  33. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @scsi, performRequest is for doing Twitter requests. It has nothing at all to do with logging a user in.
     
  34. ScsiOverdrive

    ScsiOverdrive

    Joined:
    Nov 7, 2012
    Posts:
    13
    Cool, that makes sense. Thanks again, you're the best!
     
  35. ScsiOverdrive

    ScsiOverdrive

    Joined:
    Nov 7, 2012
    Posts:
    13
    It turns out that the iOS language setting affects Twitter's login dialog after all.. I really should have tested this first. :)

    It now seems likely that the users in Brazil have their devices set to English. :)
     
  36. nah0y

    nah0y

    Joined:
    Apr 4, 2011
    Posts:
    74
    Hello,

    I'm having a problem with the Facebook plugin. I have done everything required for the configuration of both Unity and my app on dev.facebook.com :
    - on the website :
    Native iOS App Bundle ID
    Native iOS App Facebook Login (Enabled)
    Native iOS App Deep Linking (Enabled)
    Native iOS App URL Scheme Suffix fbMY_APP_ID

    - in Unity :
    Info.plit Additions CFBundle URLSchemes to fbMY_APP_ID
    Info.plit Additions Facebook App ID to MY_APP_ID

    And when logging in, I'm calling :
    Code (csharp):
    1. string[] readPermissions = new string[] { "email", "user_birthday", "user_games_activity" };
    2. FacebookBinding.loginWithRequestedReadPermissions(readPermissions);
    Here are my issues :
    1) The new Facebook Login does not appear. Instead, it opens the Facebook app and ask to login
    2) If here, I click Cancel, I'm NOT redirected to my game, but to the Facebook app

    If I click login in, of course everything works fine, but there is those 2 issues.

    I'm running iOS 6.0, and this is happening when I'm connected to Facebook through the settings of iOS, connected with the Facebook Application on the phone AND not connected with the Facebook Application on the phone.

    Is there something I forgot to config ?
    (I precise that in my Facebook website admin page, I only have selected Native iOS App and Native Android App, I don't have Website with Facebook login, App on Facebook, Mobile Web or Page Tab)

    Thanks !
     
  37. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @nah0y, read back in this topic and read FBs docs to learn when they will use the iOS native login. You get no control over the process. It is all decided and handled by FBs SDK. If FB does not reopen your app you failed to set something up properly. Your bundle ID must match, your FB ID must match, your URL scheme must be correct, etc, etc. This has come up dozens of times in this thread so read back through it and triple check all your settings and read the logs in the Organizer Console.
     
  38. nah0y

    nah0y

    Joined:
    Apr 4, 2011
    Posts:
    74
    I know it's been discussed a dozen times... but I have nothing in the logs and like I said, everything seems to be configured just fine... I'll check again through the forum though.
     
  39. darkmax

    darkmax

    Joined:
    Feb 21, 2012
    Posts:
    83
    hi, I'm having trouble with the facebook part, how can i get if i have a valid access token?, because i'm doing this:

    First i'm calling SessionValidate if returns true i use showDialog if false i ask for the permission for read and publish, but if then i revoke those permissions from my page of facebook the app sesion still valid but the token that i have is revoked so i get an error, so i also ask for the permissions with the method getSessionPermisions but returns the same value before and after i remove the app permissions from my facebook page, so the only thing i can do is re-installing the app to SessionValidate returns false and again ask for all the permissions.

    In short this is what i'm doing:
    1) init
    2) ask if session is valid
    3) if true: showDialog
    4) if false: ask permission of read and publish, then call show dialog

    So my question is on the step 2 what else i need to ask to be sure if i have a valid token?, also if the token expired and i have the already the permissions how i ask for a new one?
     
    Last edited: Nov 7, 2012
  40. games

    games

    Joined:
    Feb 18, 2012
    Posts:
    61
    Just purchased this plug-in, doing some testing.

    Does the app need to be live on the app store for functionality to work?

    Thanks.
     
  41. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @darkmax, Facebooks recommendation is to extend the access token at launch every time. The operation will return an error is the access token is no longer legit.

    @games, of course you can test without having your app in the App Store.
     
  42. darkmax

    darkmax

    Joined:
    Feb 21, 2012
    Posts:
    83
    how can i extend the access token because i search on the graph api i couldn't find a method on the graph api
     
  43. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @dark, it is documented in the Graph API docs and has been discussed multiple times in this thread.
     
  44. darkmax

    darkmax

    Joined:
    Feb 21, 2012
    Posts:
    83
    ok i will check again the thread, just another question i having a strange problem when i compile and run my project the application is launched but then i get a error and then closes, but if the i run the app manually from the ipad runs fine, i don't know if some is having the same problem?
     
  45. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @games, Facebook or Safari not being able to reopen your app is an indicator you did not follow the steps to setup your app correctly.
     
  46. SolaninMoon

    SolaninMoon

    Joined:
    Nov 8, 2012
    Posts:
    6
    Hello
    I can not speak English well. Use Google Translate.
    During the Prime31 using the Android plug-in, there's a problem.
    Facebook Login -> Facebook log out -> exit the application -> application again to turn on -> Facebook login.

    After Facebook login id, login automatically without entering a password.
    Original login window will appear

    Is there a way to fix?
     
    Last edited: Nov 8, 2012
  47. ydder

    ydder

    Joined:
    Aug 3, 2012
    Posts:
    3
    Hi Prime,

    I have logged in successfully with the plugin and the session is also valid now can I use native auth dialogue for requesting for reauthorizeWithPublishPermissions instead of Fast app switching as I dont want to take the user twice out of the app.

    Thanks..
     
  48. valkia

    valkia

    Joined:
    Jul 19, 2012
    Posts:
    7
    Hi prime,

    how do i detect if user has pressed cancel or share button on the popup Facebook dialog by using the method showDialog. The reason that I am asking this is because I found dialogCompletedEvent was still fired when user even pressed Cancel button. Thanks.
     
  49. Tano

    Tano

    Joined:
    Nov 11, 2009
    Posts:
    110
    Hi there, I've a strange problem with method "isSessionValid()"; Why this return me always false? This is my code:

    Code (csharp):
    1. FacebookAndroid.init( "xxxxxxxxx" );
    2.        
    3.         FacebookManager.loginSucceededEvent      += OnEventFacebookLogin;
    4.         FacebookManager.loginFailedEvent         += OnEventFacebookLoginFailed;
    5.         FacebookManager.loggedOutEvent           += OnEventFacebookDidLogoutEvent;
    6.         FacebookManager.accessTokenExtendedEvent += OnEventFacebookDidExtendTokenEvent;
    7.         FacebookManager.sessionInvalidatedEvent  += OnEventFacebookSessionInvalidatedEvent;
    8.        
    9.         bool isLoggedIn = FacebookBinding.isSessionValid();
    10.         if ( isLoggedIn == false ) {
    11.           Debug.Log( "The Session is Not Valid, New Login..");
    12.           //FacebookBinding.loginWithRequestedPermissions( new string [] {"publish_stream", "photo_upload"} );
    13.           FacebookAccess.login();
    14.         }
    15.         else {
    16.             Debug.Log( "The Session is Already Valid!" );
    17.         }
    Any suggests? Thanks..
     
  50. nah0y

    nah0y

    Joined:
    Apr 4, 2011
    Posts:
    74
    @prime31, ok so F****G weird... it seems my problem (with the cancel button) was coming from the bundle id in my info.plist.

    It was configured as : com.xx.${PRODUCT_NAME} with product name being yy
    And on dev.facebook.com as com.xx.yy, and it wasn't working
    So i removed ${PRODUCT_NAME} to set : com.xx.yy "manually", and the cancel now works...

    W.T.F...