3
\$\begingroup\$

This may be a common question but as a n00b I have some confusion on achieving this .

I am on a small game project and I want the user to share his / her scores on social media after completing the game .

When they post , it should be something like "Hurrayyyy ! I Scored 12345 on -My Game App Name- , Can you beat my score ? Try it ." where '-My Game App Name-' and 'Try it' should be a link directing to Google Play / Windows Store etc .

My Idea is like this :-

Social Media

Here Share This on Facebook , Share This on Google+ and Share This on Twitter are 3 UI Images with Button component attached to them .

So when the player clicks on those buttons , they should post on social media .

So how to achieve this ? I got something here , but I don't know how to use that . I will prefer not to use Facebook Unity Plugin . So can I achieve this ? I need code in c# , not in JavaScript :)

I hope you will help me to figure this out .

Regards , NB :)

\$\endgroup\$
  • \$\begingroup\$ Should use SDK. \$\endgroup\$ – Hamza Hasan Jan 18 '16 at 20:19
  • \$\begingroup\$ Thanks for the reply , can you elaborate ? Especially Google+ \$\endgroup\$ – Nicolus Buck Jan 18 '16 at 20:34
  • \$\begingroup\$ Just my recommendation, easy to use. BTW can you tell why you don't to use sdk? \$\endgroup\$ – Hamza Hasan Jan 18 '16 at 21:07
  • \$\begingroup\$ I made this tutorial where you can share screenshoots, text and url in your game in all Social Media (Facebook, Twitter, Whatsapp, Instagram, Gmail and so on) in less than 20 lines of code just with one single button: https://youtu.be/EaUsHVO_t5M \$\endgroup\$ – Roixo Games May 28 '18 at 15:45
  • \$\begingroup\$ Our Cross Platform Native Plugins - LITE provides these features (you can share to Social Media, Whats app, mail sms and more) - assetstore.unity.com/packages/tools/integration/… \$\endgroup\$ – Ayyappa Nov 17 '18 at 10:17
3
\$\begingroup\$

If you are not looking to use the SDKs you can just open a URL and the user would just have to confirm the posting. Just set a button to call the ShareToTW

private const string TWITTER_ADDRESS = "http://twitter.com/intent/tweet";
private const string TWEET_LANGUAGE = "en";
public static string descriptionParam;
private string appStoreLink = "http://www.YOUROWNAPPLINK.com";

public void ShareToTW(string linkParameter)
{

    string nameParameter = "YOUR AWESOME GAME MESSAGE!";//this is limited in text length 
    Application.OpenURL(TWITTER_ADDRESS +
       "?text=" + WWW.EscapeURL(nameParameter + "\n" + descriptionParam + "\n" + "Get the Game:\n" + appStoreLink));
}
\$\endgroup\$
  • \$\begingroup\$ but this ll post only via browser right? i want to share it using fb app installed in mobile. but i don't want to integrate SDK. what i want to do? \$\endgroup\$ – Manoj Balaji M Dec 3 '16 at 6:51
0
\$\begingroup\$

I know this is an old post, but just incase people come across this question again, I'll share some of my experience/research for integrating Social Media in Unity so far.

Facebook SDK

Platforms: Android and iOS

For anyone wanting to integrate Facebook login/logout, sharing, and invite functionality - or any of those combinations, I would highly recommend the Facebook SDK which is free on the Unity asset store:

Facebook SDK for Unity (beta)

I used this video tutorial to help get started with Facebook Unity integration:

Facebook SDK 7.4 in Unity 5.3

To share a score you can use the ShareLink function and get the score variable and post that in the description or title for ShareLink.

Let's Tweet In Unity

Platforms: Android and iOS

I tried to work with the Let's Tweet In Unity plugin, but so far I am having difficulties posting a status update in Twitter. I can get access to the account and verified it for Twitter developer, but no luck yet. It is free though and sounds like it would work well once it has been set up properly:

Let's Tweet In Unity Plugin

NOTE: With this Twitter plugin to work with Unity v5+, you have to change the HashTables to Dictionary - so instead of Hashtable, you would have Dictionary < string, string >

To share a score here again accessing the score variable, you should be able to pass in the score as the text parameter for the PostTweet function - although, I am having trouble getting this function to work for me, I assume it would be that simple.

Unishare

Platforms: Android and iOS

There is also the UniShare plugin, but this one costs $7.99. But seems able to share text as well as in game screenshots - and shares to any sharing media type on mobile:

Unishare Unity Plugin

I am unsure how the code works for this plugin because I have not bought it, but I assume there is a simple way to add a standard text message including your score to the share link.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the reply :) As I am busy right now, I am somewhat away from Unity , But I will try it in future :) \$\endgroup\$ – Nicolus Buck Sep 6 '16 at 14:25
  • \$\begingroup\$ Yeah no problem! Good luck with it. :-) \$\endgroup\$ – 101_son Sep 6 '16 at 15:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.