Lets learn how to invite and share our game.
Watch the full video for an in-depth explanation of how to put this all together. However if you just want a quick cheat sheet of how to do shares and invites then look no further than the following code:
Sharing
public void Share()
{
FB.FeedShare (
string.Empty,
new Uri("http://linktoga.me"),
"Hello this is the title",
"This is the caption",
"Check out this game",
new Uri("https://i.ytimg.com/vi/NtgtMQwr3Ko/maxresdefault.jpg"),
string.Empty,
ShareCallback
);
}
void ShareCallback(IResult result)
{
if (result.Cancelled) {
Debug.Log ("Share Cancelled");
} else if (!string.IsNullOrEmpty (result.Error)) {
Debug.Log ("Error on share!");
} else if (!string.IsNullOrEmpty (result.RawResult)) {
Debug.Log ("Success on share");
}
}
Inviting
public void Invite()
{
FB.Mobile.AppInvite (
new Uri("http://linktoga.me"),
new Uri("https://i.ytimg.com/vi/NtgtMQwr3Ko/maxresdefault.jpg"),
InviteCallback
);
}
void InviteCallback(IResult result)
{
if (result.Cancelled) {
Debug.Log ("Invite Cancelled");
} else if (!string.IsNullOrEmpty (result.Error)) {
Debug.Log ("Error on invite!");
} else if (!string.IsNullOrEmpty (result.RawResult)) {
Debug.Log ("Success on Invite");
}
}
Check the resources sidebar where you can download the full source code of this tutorial.
If you have any issues, please ask your questions in the support thread from the forum below this article or go to the full thread on the forums here
Happy Coding!
Glenn