Search Unity

Is it really that hard to share a simple score on Facebook and Twitter natively?

Discussion in 'Editor & General Support' started by Laumania, Feb 28, 2014.

  1. Laumania

    Laumania

    Joined:
    Jun 27, 2012
    Posts:
    221
    Hi

    I'm doing a game and would like to give the user the ability to share his/hers score after end game.
    I don't want an app on Facebook or anything.

    I just want to open up the "native" sharing UI, where I provide the text/image/link and then the user post it them self to twitter, facebook, email etc.

    Can it really be correct that it's so hard to find a plugin to help me with that? I need it to work on both iOS and Android (Windows Phone if possible), but right now I can't seem to find a plugin that does this simple thing...all I find are plugins that either do the share UI them self in-game or need and Facebook app id, to post on behalf of the user.

    Any one who can help out there?
     
  2. Laumania

    Laumania

    Joined:
    Jun 27, 2012
    Posts:
    221
  3. Trilusion

    Trilusion

    Joined:
    Mar 20, 2013
    Posts:
    60
    Maybe this is enough for you:

    Code (csharp):
    1. string facebookshare = "https://www.facebook.com/sharer/sharer.php?u=" + Uri.EscapeUriString(appStoreLink);
    2. Application.OpenURL(facebookshare);
    3.  
    4. string twittershare = "http://twitter.com/home?status=" + Uri.EscapeUriString(appStoreLink);
    5. Application.OpenURL(twittershare);
     
    Sermer likes this.
  4. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    You can OAuth2 and post/get commands to pass info between social networking apis.

    Uses the www class similar to posting to php highscore board, and the returned object is a hash with user info that was requested.


    I use vuforia and it doesn't play well with other plugins that require main activity so I've beat my head against the wall for a long time getting crap to work with facebook and twitter and vuforia.

    Unishare in the asset store is the closest plugin I've seen to native. You can also try the official FB unity plugin.
     
    Last edited: Feb 28, 2014
  5. Omer.Hussain

    Omer.Hussain

    Joined:
    Dec 16, 2013
    Posts:
    5
    Have you found the solution i am also looking for FB simple score sharing but no result yet .... :(
     
  6. eskimojoe

    eskimojoe

    Joined:
    Jun 4, 2012
    Posts:
    1,440
  7. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    Facebook has there own unity thing. Posting to facebook is alot more complex then it should be.''https://developers.facebook.com/docs/unity/
     
  8. StevenMCH

    StevenMCH

    Joined:
    Feb 15, 2014
    Posts:
    16
    Not sure if this helps: https://www.assetstore.unity3d.com/en/#!/content/17803

    It focus on FB leaderboard, but also allows posting scores. You will need to create an AppID though, as per the normal Facebook requirement. I don't think Facebook allows bypassing or posting without linking your App to Facebook.

    Hope it helps :(
     
  9. fedor.shubin

    fedor.shubin

    Joined:
    Oct 12, 2014
    Posts:
    3
    Sometimes it's better to use standard platform-specific sharing functionality.
    It's sharing intent in Android. And in iOS it's new social functionality included stating iOS6.

    I created small package for my internal purposes that allows to easily integrate such kind of solution to your games. It's available for free at: https://github.com/vedi/share-bunch-unity3d. Currently it supports just text sharing, but it can be easily extended.

    Any feedback is appreciated.
     
    shortlin likes this.
  10. testingdemi

    testingdemi

    Joined:
    Jan 26, 2015
    Posts:
    8
  11. spirit_lancer

    spirit_lancer

    Joined:
    Nov 25, 2014
    Posts:
    4
    So there is no need to setup the app in facebook? It is only for ios right? is there anyway i can do it for android too???
     
  12. calmcarrots

    calmcarrots

    Joined:
    Mar 7, 2014
    Posts:
    654
    Download the Facebook SDK for unity. Look at the example and bam! You know how to integrate Facebook. It works on iOS a d android. I have done this in my app. Its not that hard. Don't install 3rd party stuff. I think its better to learn now and experience this kind of stuff. Just trust me, follow the Facebook instructions and just look at the examples. It works.


    It also only takes like 30 lines of code (code that you can copy and paste from their examples)
     
  13. spirit_lancer

    spirit_lancer

    Joined:
    Nov 25, 2014
    Posts:
    4
    is there anyway to do sharing without setting the app up at facebook?
     
  14. calmcarrots

    calmcarrots

    Joined:
    Mar 7, 2014
    Posts:
    654
    Nope. Trust, just get that part over with and you never have to worry about ever again. All of your apps will be easy to put Facebook in because you have all the code you need. When I get home later, I will see if I can send you the code you need.
     
  15. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    I'm thinking of doing the same thing (sans the part where the game asks for access to your entire friends lists to spam their feeds) and will use Facebook SDK for Unity too. Good luck & have fun.
     
  16. calmcarrots

    calmcarrots

    Joined:
    Mar 7, 2014
    Posts:
    654
    Code (csharp):
    1.  
    2. public void PostFacebook()
    3.     {
    4.         if (!FB.IsLoggedIn)
    5.         {
    6.             FB.Login("email,publish_actions");
    7.         }
    8.         else
    9.         {
    10.             Util.Log("onShareClicked");
    11.             FB.Feed(
    12.                     linkCaption: "I popped " + highScore.ToString() + " circles! Can you beat it?",
    13.                     picture: "<INSERT A LINK TO A PICTURE HERE>",
    14.                     linkName: "Checkout Circle Pop on iOS and Android!",
    15.                     link: "http://apps.facebook.com/" + FB.AppId + "/?challenge_brag=" + (FB.IsLoggedIn ? FB.UserId : "guest")
    16.                     );
    17.         }
    18.     }
    19.  
    20.     void OnLoggedIn()
    21.     {
    22.         Util.Log("Logged in. ID: " + FB.UserId);
    23.     }
    24.  
    25.     private void SetInit()
    26.     {
    27.         Util.Log("SetInit");
    28.         if (FB.IsLoggedIn)
    29.         {
    30.             Util.Log("Already logged in");
    31.             OnLoggedIn();
    32.         }
    33.     }
    34.  
    Just post that there somewhere in your code. Connect the PostFacebook function to a UI button. After that, import the Facebook SDK into your unity project. Setup you facebook app page and connect it to your unity project. Lastly, make sure you import the UTIL class from the Facebook examples. That is all you need to do! It's super simple. No need for any plugins or anything.

    EDIT: Forgot to mention, call SetInit(); in your Awake() function
     
    Last edited: Mar 8, 2015
    Voronoi likes this.
  17. spirit_lancer

    spirit_lancer

    Joined:
    Nov 25, 2014
    Posts:
    4
    ya... :( i did once but the guy i am working for dont want to setup the app on fb. Since for android i will need to add keyhash everytime he uses new keys...
    for ios has a workaround though.. .tnx :)
     
  18. g0ldfighter

    g0ldfighter

    Joined:
    Mar 3, 2015
    Posts:
    2
    I tried implementing your original project in unity 5. There's a bundle identifier failure which doesn't seem to go no matter what I do.
     
  19. g0ldfighter

    g0ldfighter

    Joined:
    Mar 3, 2015
    Posts:
    2
    I imported it in my current project and it's working really smooth. A million thanks for the plugin. :)
     
  20. drewfus

    drewfus

    Joined:
    Nov 22, 2013
    Posts:
    1
    This works like a charm.

    One problem: the string doesn't transfer to the Facebook share. This is a problem with facebook only.

    I assume I need to do all the standard facebook stuff, but how do I integrate that with this code?
     
  21. Badwoof

    Badwoof

    Joined:
    Jan 10, 2015
    Posts:
    14
    The share bunch plugin works well on Android, but causes a crash on IOS.
    Anyone else have that problem also?

    I'm loathe to put apps on facebook as required by their sdk. So I've been avoiding using that directly.
    And I flat out refuse to require users to log in to facebook to play, or even prompt them to.
    That's a deal breaker on me playing a game, so I won't have it in mine.

    I just want an easy way to let users share if they want to via whatever method they want.
    So far, the share bunch method is closest, but I'm having a problem with it.
     
  22. shortlin

    shortlin

    Joined:
    Oct 30, 2014
    Posts:
    22
    I found his plugin has a mistate in XCodePostProcess.cs .

    The code must tried to find a file which is name is "NativeGateway.projmods".But it tried to find "._NativeGateway.projmods",the file which is hide by unity...

    So I tried change the code..:

    nd run through all projmods files to patch the project.
    // Please pay attention that ALL projmods files in your project folder will be excuted!
    string[] files = Directory.GetFiles( Application.dataPath, "*.projmods", SearchOption.AllDirectories );
    //foreach( string file in files ) {
    //UnityEngine.Debug.Log("ProjMod File: "+file);
    //Debug.Log (files.Length);
    project.ApplyMod( files[1] ); //} //TODO implement generic settings as a module option
    //}


    the bold text is changed by me.
    it worked.

    But my target is tried to cached the screenshot to share.I also found this
    http://www.theappguruz.com/unity/general-sharing-in-android-ios-in-unity/
    but It could not work in ios..so any body has a idea with native share the screen shot to ios?
     
  23. Boxed-Pig

    Boxed-Pig

    Joined:
    Feb 10, 2015
    Posts:
    2
    Share Bunch also worked fine for me on iOS, except sending the text to facebook.
    Anyone else, besides me and drewfus, with this problem?
    It's the best solution so far, but unfortunately the facebook problem is a deal breaker.

    Edit: Did some live tests and find out the facebook text is there, it is just not showing on the share requester. If you post, it will carry through to your timeline.
     
    Last edited: Jun 8, 2015
  24. Badwoof

    Badwoof

    Joined:
    Jan 10, 2015
    Posts:
    14
    From what I can tell it was something that changed in IOS that was causing it to simply crash on me (ios 8.1). I probably could have figured it out in a day, but it was easier to go with a different native solution that worked quite well from the asset store.
    https://www.assetstore.unity3d.com/en/#!/content/9277

    Not fancy, but does the basic stuff I want without hassles.
     
  25. Boxed-Pig

    Boxed-Pig

    Joined:
    Feb 10, 2015
    Posts:
    2
    Yeah, I think you are right, Badwoof.
    It worked on iPhone 4 and 4s, up until iOS 8.1.3 but failed on two iPhone 6 with 8.3.
    Any chance for an update, fedor.shubin? I really liked your solution.
     
  26. shortlin

    shortlin

    Joined:
    Oct 30, 2014
    Posts:
    22
    I found soomla recent develop native share afterwards.(the guy which develope bunch share had went to there work)
    It's very easy,just one line code.(http://know.soom.la/unity/profile/profile_mainclasses/#MultiShare)
    But the plug- in you should not download from asset store.because it's an old version.
    You should download here.https://github.com/soomla/unity3d-profile
    import two packge: soomla-unity3d-core. and soomla-unity3d-profile
    It is my code like:

    Application.CaptureScreenshot("MyImage.png");

    SoomlaProfile.MultiShare("share words",
    Application.persistentDataPath + "/MyImage.png"
    );​
    But I can't use it in android facebook(It works in ios ),So I use this plugin(http://www.theappguruz.com/unity/general-sharing-in-android-ios-in-unity/) in android

    And I found there are many guys said native share can't share text which is set in facebook.But for me it can share.It's enough.
     
    Last edited: Jun 12, 2015
  27. jegali

    jegali

    Joined:
    Jan 20, 2013
    Posts:
    1
    Hi there,

    @calmcarrots: I'd like to share scores achieved in my unity app to facebook. I created an app, everything works fine so far - but I'm the only one who can see my posts. As far as I know, I have to submit my unity app to facebook. Therefore I need a privacy policy statement.Can you tell me what is needed for a

    - login
    - "I achieved blablabla"

    Is there a template for a policy template which I can use?

    Cheers,
    Jens
     
  28. calmcarrots

    calmcarrots

    Joined:
    Mar 7, 2014
    Posts:
    654
    Try looking into a privacy policy generator. Here are some I found online:
    https://www.generateprivacypolicy.com/
    https://www.freeprivacypolicy.com/
    http://www.bennadel.com/coldfusion/privacy-policy-generator.htm

    Search results:
    https://www.google.com/webhp?source...=1&espv=2&ie=UTF-8#q=privacy policy generator
     
  29. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,965
    Adding to the list incase any one interested.

    Sharing feature is completely available for FREE in Cross Platform Native Plugins Lite version .

    Sharing feature contains following functionalities

    • Share Screenshot, Image, text, url via SMS

    • Share Screenshot, Image, text, url via E-Mail

    • Share Screenshot, Image, text, url via Whats-app

    • Share Screenshot, Image, text, url on Social Network (Facebook, Twitter)
    Adding to it we added separate Twitter SDK feature in full version for Twitter login functionalities.
     
    ilmario likes this.
  30. EA-developers

    EA-developers

    Joined:
    Jun 28, 2015
    Posts:
    4
    I agree With you (Y)
     
  31. JeffersonTD

    JeffersonTD

    Joined:
    Feb 5, 2013
    Posts:
    268
    I'm also a bit bummed at how things just don't work as expected with Facebook. I'm trying to have a simple share, that would have
    - a text I want.
    - a link.
    - screenshot.

    For Twitter this works simply with this line of code using the u3dxt package :
    SocialXT.Post (SLRequest.SLServiceTypeTwitter, "Yo, this is a message", someTexture, someUrl);​

    But for Facebook this doesn't work properly (at least not any more):
    SocialXT.Post(SLRequest.SLServiceTypeFacebook, "Yo, this is a message", someTexture, someUrl);
    It does post, but it doesn't have the preset message and it doesn't have any picture. You can just type in what you want.

    I also tried using the FB.Feed:
    FB.Feed(linkCaption: "Yo, this is message",
    linkName: "Yeah yeah title!",
    link: shareLinkUrl);
    This APPEARS to work better when you're shown the dialogue: you see the linkName and the linkCaption in the popup window. However, when you check the post on Facebook, it only has the name and caption defined by the page that resides in the link. This is okay, in principle, but I need to have some way of putting some preset message at least ("I scored X points..."). And it would be really nice to be able to have that screenshot there too, just like for Twitter.

    So: eg. simply using the FB.Feed or Facebook's own Unity SDK, how can I set a preset text and a link? And is it possible to share a picture?
     
  32. kafanasiff

    kafanasiff

    Joined:
    Sep 25, 2013
    Posts:
    31
    Thank you Trilusion, you are our only hope. That is the answer I was looking for.
     
  33. ShuchiSingla

    ShuchiSingla

    Joined:
    Feb 9, 2019
    Posts:
    2
    Hi everyone,
    Is their any way to get if anyone is actually sharing the post.
     
  34. nick11235

    nick11235

    Joined:
    Sep 23, 2016
    Posts:
    1
    You can giveaway some prizes (in game currency) whoever shares will rise considerable...try your luck!