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

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

  1. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @recluse, that means you arent using the same method when subscribing/unsubscribing. They must match exactly. Check the *EventListener class and notice that all the subscribed methods are identical to those removed.
  2. Recluse

    Recluse

    Member

    Joined:
    May 16, 2010
    Messages:
    326
    Yes, I see that. Fixed it.

    Everything's working nicely now. It seems my URLs weren't getting wrapped when the tweet message string was a public variable, editable in the inspector. Making it private fixed that.
  3. Recluse

    Recluse

    Member

    Joined:
    May 16, 2010
    Messages:
    326
    Any thoughts on whether I should load my networking event manager prefab in the first scene, or would it be ok to wait until the tweet scene (which is the only place in the game that tweeting occurs)?
  4. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @recluse, you can always just instantiate the prefab on demand, then destroy it when you dont need it. Either that or sticking it in your initial loading scene will work.
  5. Masashi Wada

    Masashi Wada

    Member

    Joined:
    Jul 6, 2010
    Messages:
    22
    Hi prime.

    We thank your verification.
    I wished you looked at it and sent the detailed private message.
  6. vaclav87

    vaclav87

    New Member

    Joined:
    Sep 12, 2011
    Messages:
    4
    Is xAuth required for showTweetComposer as well? It doesn't seem to work when I try to call it after logging in with showOauthLoginDialog.
  7. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @vaclav, Xauth is not required for anything at all. The tweet composer only works on iOS 5 when the user has a Twitter account setup.
  8. vaclav87

    vaclav87

    New Member

    Joined:
    Sep 12, 2011
    Messages:
    4
    @Prime31, Is there any way to check if account is set up? Is it isTweetSheetSupported?

    Regarding xAuth, is logging in throug showOauthLoginDialog enough to use postStatusUpdate? I tried this and it seems it wasn't working, but it's possible I was doing something wrong.
  9. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @vaclav, there are two methods to check: isTweetSheetSupported an canUserTweet. Any successful login will have an access token. That is all you need to post and use all the other methods.
  10. quitebuttery

    quitebuttery

    Member

    Joined:
    Mar 12, 2011
    Messages:
    200
    Anyone getting a crash with showTweetComposer? Whether I pass it a filepath or not (a null string) the native plug-in crashes with a bad image pointer in showTweetComposerWithMessage. Where's it getting this filepath if I'm not even passing it one to begin with?
  11. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @quite, I cant reproduce what you are seeing. We did push out an update earlier today but it only contained very minor tweaks for Xcode 4.3. You may want to give that a shot.
  12. quitebuttery

    quitebuttery

    Member

    Joined:
    Mar 12, 2011
    Messages:
    200
    I think that's the update I have--the asset store isn't saying I can update. Although it says 1.0 feb 2nd in the Asset Store version.
  13. quitebuttery

    quitebuttery

    Member

    Joined:
    Mar 12, 2011
    Messages:
    200
    Is the Asset Store version in sync with the other build?
  14. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @quite, the Asset Store is always a little bit behind due to the review process. You should see the update in there soon.
  15. quitebuttery

    quitebuttery

    Member

    Joined:
    Mar 12, 2011
    Messages:
    200
    Ok well I'll wait until it shows up--the only other thing I can think of is I'm using 3 or 4 other plug-ins. I dunno if there are any conflicts.
  16. quitebuttery

    quitebuttery

    Member

    Joined:
    Mar 12, 2011
    Messages:
    200
    I found the bug. You aren't initializing the UIImage pointer to null in

    void _twitterShowTweetComposer( const char * status, const char * imagePath )

    Can you fix that in the next patch?
  17. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @quite, it is already submitted for review in the next update. Tht was part of the changes for Xcode 4.3. Previous compilers didn't require niling pointers.
  18. swiv

    swiv

    New Member

    Joined:
    Mar 22, 2009
    Messages:
    30
    Hi Prime31,

    I've been getting far with your plugins. One thing that happens when using the Social Media plugin is that i get a number of warnings come up in the xcode output stream which all say the same thing:

    warning: No copy of <No file name> found locally, reading from memory on remote device. This may slow down the debug session.

    This doesn't seem to affect the game at all, but I don't know what it means. Have you seen this before at all? And if so should I be worried about it. Thanks for any help.
  19. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @swiv, those messages have nothing to do with the plugin. They are just telling you the state of the debugging session with regard to the frameworks of iOS. You can ignore them.
  20. swiv

    swiv

    New Member

    Joined:
    Mar 22, 2009
    Messages:
    30
    Oh ok... thanks for the reply!
  21. Masashi Wada

    Masashi Wada

    Member

    Joined:
    Jul 6, 2010
    Messages:
    22
    hi prime.

    Was your response decided about the phenomenon which I sent to you?
    Our project is waiting for your reply.
    Our development is not finished unless action of the plug-in is decided.
  22. swiv

    swiv

    New Member

    Joined:
    Mar 22, 2009
    Messages:
    30
    Hi Prime31, I am using the Social Networking plugin to bring up the PostMessageDialog so the user can post a message about their score at the end of the game. Is it at all possible to change the size of the facebook dialog at all? (I'd like mine bigger on the screen on my ipad). Thanks for any advice.
  23. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @swiv, the size of the dialogs is handled by Favebook. If you wanted to change the size you would have to modify the code in their SDK that sets it up.
  24. swiv

    swiv

    New Member

    Joined:
    Mar 22, 2009
    Messages:
    30
    Another quick question Prime31 if you don't mind. I am building with Unity 3.42. I have autoRotation set in the Unity build settings. My game rotates properly, and the game centre interface which I bring up with your plugin also rotates along with the game properly. However, the Facebook dialogs that I bring up with your SocialNetworking plugin do not (the game rotates but the FB dialogs stay in the same position). Is this something we have to live with or am I doing something wrong?

    Many thanks for any help.
  25. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @swiv, the FB dialogs are all handled by the Facebook SDK. You can probably modify their code to support autorotation. I just tested on an iPhone and it definitely works there (I don't have an iPad handy to test with). Do you have the "animated" checkbox checked in Unitys settings?
  26. swiv

    swiv

    New Member

    Joined:
    Mar 22, 2009
    Messages:
    30
    Thanks for the quick reply. I've narrowed it down. The dialog does rotate.. but if you start to type into a text area (say on the FB post message dialog), the IOS keyboard comes up. Then if you rotate, everything (including the IOS keyboard) rotates, but he FB dialog stays in the same position. If you then press the button on the IOS keyboard to remove it from the screen (bottom right key), the FB dialog stays in the same position until you initiate a new rotate by tilting the iPad. Are you able to replicate that behaviour? If so is it something that can be fixed (I guess not if it's handled by the Facbook SDK)? Many thanks.
  27. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @swiv, sound like the FB crew can use a bug report :)
  28. swiv

    swiv

    New Member

    Joined:
    Mar 22, 2009
    Messages:
    30
  29. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @swiv, we avoid modifying any wrapped SDK's to keep things compatible for future updates but you are free to modify the Facebook SDK with any changes that you want.
  30. swiv

    swiv

    New Member

    Joined:
    Mar 22, 2009
    Messages:
    30
    I can confirm that the fix on the stackoverflow post works. Hopefully FB will fix in the next version. Many thanks
  31. swiv

    swiv

    New Member

    Joined:
    Mar 22, 2009
    Messages:
    30
    Hi Prime,

    Finished implementing your FB plugin and it's working really great. Now I'm onto the Twitter plugin and I have a quick question.

    I am currently using the OAuth login. (I will request xAuth, but from reading other replies it doesn't seem likely I'll get one). Anyway, when I bring up the OAuth login, I get the Twitter login in an overlaid webpage as I should.

    However, if I click on "Cancel, and return to App" the webpage displays my homepage within the overlaid browser window (i presume this is because I have that set in the twitter app settings somewhere).

    Is there anyway to close the popup when pressing the "cancel" html link? Like some sort of Javascript code on the resultant page that will close the popup window? Note, I'm talking about the cancel link within the popup webpage window, not the "cancel" button at the top of the popup control (that works fine).

    Thanks for any help.
  32. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @swiv, there is currently no way to detect and close the view when any HTML buttons or links are touched.
  33. Masashi Wada

    Masashi Wada

    Member

    Joined:
    Jul 6, 2010
    Messages:
    22
    hi prime.

    I wished you looked at it and sent the detailed private message.

    Was your response decided about the phenomenon which I sent to you?
    Our project is waiting for your reply.
    Our development is not finished unless action of the plug-in is decided.
  34. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @Masashi, if you leave the animated checkbox unchecked in the player settings or if you manually set the orientation via code proper native iOS autorotation is not possible.
  35. cloyst3r

    cloyst3r

    New Member

    Joined:
    Mar 1, 2012
    Messages:
    1
    Hello Prime,

    I've implemented your plugin, FB works perfect but I have a little issue with TW. I'm using OAuth and after I login and select "Authorize app", i'm redirected back to my app, TwitterBinding.isLoggedIn() is true, TwitterBinding.loggedInUsername() is correct, but when I' trying to call TwitterBinding.postStatusUpdate() nothing happens, no tweet. But, if i manually close my app and relaunch it again, the TwitterBinding.postStatusUpdate() call works fine.

    Any idea :-?
  36. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @cloyst, make sure the text you send is different each time. Twitter won't post the same text twice.
  37. Pip Robbins

    Pip Robbins

    Member

    Joined:
    Oct 19, 2010
    Messages:
    213
    Hey prime31,

    Are any of your applications capable of knowing when a user "likes" you on facebook, twitter or reviews your game on the app store. We would like to reward the player with free content and in game currency.

    If not, any suggestions for how to achieve this in unity.

    As a example - by reviewing the game, you are rewarded with a entire level bundle and liking us on facebook and twitter would be rewarded with store credits/alternative character models/free hints (puzzle game).

    Thanks,
    Pip
  38. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @Pip, The SocialNetworking Plugin gives you full access to the Facebook Graph API and Twitters entire API. You can query anything you want with them.
  39. loock_

    loock_

    New Member

    Joined:
    Aug 4, 2010
    Messages:
    18
    Hello,

    I've bought the Social Networking Plugin and after installation I've launched the test scene providing my own FB appID (in init function and .plist file with "fb" prefix). However, after build (via Build in Build Settings) and run in Xcode and opening my app, I click Inititialize and then Login -> Safari opens with the proper page of my app but it causes an app crash.. In Xcode console I can see following message:
    Then, after providing my login data, Safari window closes and I'm back to my crashed app (stuck on the splash screen).
    What can be the cause of this crash? Settings of my FB app? Settings of the plugin? Everything is default..

    Please help!
  40. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @look, I can't reproduce the error when using the demo scene. Can you send over a stack trace? To get it when the crash occurs type "thread apply bt all" in the Xcode console.
  41. NT7Games

    NT7Games

    New Member

    Joined:
    May 21, 2009
    Messages:
    43
    Just set up a new Facebook App for a demo project I'm doing.

    Here's what I think I'm doing right:

    - I have the App details set up with Apple (so I have a bundle ID and an App ID)
    - I have a FB App set up with a FB App ID / API Key and a FB Secret

    I call the following code:
    Code (csharp):
    1.  
    2.        void Awake()
    3.     {
    4.         FacebookBinding.init("xxxxxxxxx"); // My API key
    5.     }
    6.    
    7.     // Use this for initialization
    8.     void Start () {
    9.        
    10.         StartCoroutine(FacebookLoginCoroutine());
    11.     }
    12.    
    13.     IEnumerator FacebookLoginCoroutine()       
    14.     {
    15.         yield return new WaitForSeconds(2.0f);
    16.        
    17.         if(!FacebookBinding.isLoggedIn())
    18.         {
    19.             string[] perms = new string[3];
    20.             perms[0] = "publish_actions";
    21.             perms[1] = "publish_stream";
    22.             perms[2] = "email";
    23.            
    24.             Debug.Log("Logging into Facebook");
    25.             FacebookBinding.loginWithRequestedPermissions(perms);
    26.         }
    27.         else
    28.         {
    29.             Debug.Log("Extending Token");
    30.             FacebookBinding.extendAccessToken();
    31.         }
    32.     }
    The Debugger outputs "Logging Into Facebook" - so I know that FacebookBinding.loginWithRequestedPermissions(perms); is getting called. Why, then, is the user directed to their own news feed and not the App authorization screen!?!?

    Finally, I have set up the Info.pList additions as outlined in the API Docs on prime31.com, and verified that the .pList file in the XCode project has the URL Scheme inside it.

    I can't see anything different between this and the previous FB app I've set up. Really bonkers and suggestions would be appreciated.
  42. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @NT7, did you add your bundle ID to the Facebook app? They require it now in order to be able to authorize and redirect back to your app.
  43. NT7Games

    NT7Games

    New Member

    Joined:
    May 21, 2009
    Messages:
    43
    @Prime31, I did. I placed my Apple ID (retrieved from iTunes connect) into the iPhone App Store ID field on my Facebook Developer page.
  44. NT7Games

    NT7Games

    New Member

    Joined:
    May 21, 2009
    Messages:
    43
    and yes, also my Bundle ID as well (com.nt7inc.<XYZXYZ>)
  45. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @NT7, the last bit would be to delete your game from the device between tests so that the Info.plist changes propagate. Xcode has a bug where Info.plist changes only take effect on install sometimes.
  46. NT7Games

    NT7Games

    New Member

    Joined:
    May 21, 2009
    Messages:
    43
    Yeah I'm retarded. I was using my app secret in the init method instead of the FB App ID. Will test and confirm my retardedness.

    [EDIT]: will also delete app data from my phone before testing.

    </duh>
    Last edited: Mar 2, 2012
  47. NT7Games

    NT7Games

    New Member

    Joined:
    May 21, 2009
    Messages:
    43
    Fixed. Thanks for suggesting the BundleID thing because it led me down the right path anyway :)
  48. innercircus

    innercircus

    New Member

    Joined:
    Aug 19, 2009
    Messages:
    15
    hello Prime31, great plugins, have quick question about the FB part of the social media plugin.

    I've read through the forum several times now and double / triple checked my settings and FacebookBinding.postImage doesn't seem to return any callback info? even though the image does post to facebook. Any insight for me? :) thanks in advance!

    1. plist setup properly.
    2. fb init called properly.
    3. have my social networking prefab added to my root scene (I'm on a different scene when calling it but that's worked for etc manager, and media manager so I assume I'm cool ;)
    4. it's in javascript (I can already feel you discontent) :)
    5. xcode 4.3 installed building to ios 5
    6. using the 2-21-12 social media plugin.
    7. 3.5.0f5 build of unity3d.

    Code (csharp):
    1.  
    2. // called when I push a  button...
    3. function db_facebook(){
    4.     if(FacebookBinding.isLoggedIn()){
    5.         var mess = GameObject.Find("message").GetComponent(Input_Generic).text;
    6.         FacebookBinding.postImage( gm.selectedGalleryImagePath, mess );
    7.     }
    8.     else{
    9.         FacebookBinding.login();
    10.     }
    11. }
    12.  
    13. function twitterLogin(){
    14.     //EtceteraBinding.showAlertWithTitleMessageAndButton( "Success", "logged into twitter successfully!", "OK" );
    15. }
    16. function twitterPost(){
    17.     EtceteraBinding.showAlertWithTitleMessageAndButton( "Success", "You've Tweeted your awesome creation!", "OK" );
    18. }
    19. function twitterPostFailed(error:String){
    20.     EtceteraBinding.showAlertWithTitleMessageAndButton( "FAILURE!", "oops! Something muffled your Tweet! ::"+error, "OK" );
    21. }
    22. function facebookLogin(){
    23.     //EtceteraBinding.showAlertWithTitleMessageAndButton( "Success", "logged into facebook successfully!", "OK" );
    24. }
    25. function facebookPost(){
    26.     EtceteraBinding.showAlertWithTitleMessageAndButton( "Success", "You've posted your awesome creation to Facebook!", "OK" );
    27. }
    28.  
    29. function facebookPostFailed(error:String){
    30.     EtceteraBinding.showAlertWithTitleMessageAndButton( "FAILURE!", "oops! Something busted posting to Facebook! :: "+error, "OK" );
    31. }
    32.  
    33. function OnEnable(){
    34.     SocialNetworkingManager.twitterLogin += twitterLogin;
    35.     SocialNetworkingManager.twitterPost += twitterPost;
    36.     SocialNetworkingManager.twitterPostFailed += twitterPostFailed;
    37.     SocialNetworkingManager.facebookLogin += facebookLogin;
    38.     SocialNetworkingManager.facebookPost += facebookPost;
    39.     SocialNetworkingManager.facebookPostFailed += facebookPostFailed;
    40. }
    41. function OnDisable(){
    42.     SocialNetworkingManager.twitterLogin -= twitterLogin;
    43.     SocialNetworkingManager.twitterPost -= twitterPost;
    44.     SocialNetworkingManager.twitterPostFailed -= twitterPostFailed;
    45.     SocialNetworkingManager.facebookLogin -= facebookLogin;
    46.     SocialNetworkingManager.facebookPost -= facebookPost;
    47.     SocialNetworkingManager.facebookPostFailed -= facebookPostFailed;
    48. }
  49. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @inner, stick the *EventListener prefab in your scene during testing. It will dump the contents of every event to the console. The custom request event is the one you will want for this situation though.
  50. innercircus

    innercircus

    New Member

    Joined:
    Aug 19, 2009
    Messages:
    15
    Sweet, SocialNetworkingManager.facebookReceivedCustomRequest += facebookReceivedCustomRequest; worked like a charm thanks prime! :) you da man!