Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions UnitySDK/Assets/FacebookSDK/Examples/Scripts/MenuBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,49 @@ protected void HandleResult(IResult result)
LogView.AddLog(result.ToString());
}

protected void HandleLimitedLoginResult(IResult result)
{
if (result == null)
{
this.LastResponse = "Null Response\n";
LogView.AddLog(this.LastResponse);
return;
}

this.LastResponseTexture = null;

// Some platforms return the empty string instead of null.
if (!string.IsNullOrEmpty(result.Error))
{
this.Status = "Error - Check log for details";
this.LastResponse = "Error Response:\n" + result.Error;
}
else if (result.Cancelled)
{
this.Status = "Cancelled - Check log for details";
this.LastResponse = "Cancelled Response:\n" + result.RawResult;
}
else if (!string.IsNullOrEmpty(result.RawResult))
{
this.Status = "Success - Check log for details";
this.LastResponse = "Success Response:\n" + result.RawResult;
}
else
{
this.LastResponse = "Empty Response\n";
}

String resultSummary = "Limited login results\n\n";
var profile = FB.Mobile.CurrentProfile();
resultSummary += "name: " + profile.Name + "\n";
resultSummary += "id: " + profile.UserID + "\n";
resultSummary += "email: " + profile.Email + "\n";
resultSummary += "pic URL: " + profile.ImageURL + "\n";
resultSummary += "friends: " + String.Join(",", profile.FriendIDs) + "\n";

LogView.AddLog(resultSummary);
}

protected void OnGUI()
{
if (this.IsHorizontalLayout())
Expand Down
48 changes: 41 additions & 7 deletions UnitySDK/Assets/FacebookSDK/Examples/Scripts/SubMenus/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,37 @@ protected override void GetGui()
GUILayout.BeginHorizontal();

GUI.enabled = enabled && FB.IsInitialized;
if (this.Button("Login"))
if (this.Button("Classic login"))
{
this.CallFBLogin();
this.Status = "Login called";
this.CallFBLogin("enabled");
this.Status = "Classic login called";
}

GUI.enabled = FB.IsLoggedIn;
if (this.Button("Get publish_actions"))
{
this.CallFBLoginForPublish();
this.Status = "Login (for publish_actions) called";
}

GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();

if (this.Button("Limited login"))
{
this.CallFBLogin("test");
this.Status = "Limited login called";

}
if (this.Button("Limited login +friends"))
{
this.CallFBLogin("test+friends");
this.Status = "Limited login +friends called";

}


GUI.enabled = FB.IsLoggedIn;


// Fix GUILayout margin issues
GUILayout.Label(GUIContent.none, GUILayout.MinWidth(ConsoleBase.MarginFix));
GUILayout.EndHorizontal();
Expand Down Expand Up @@ -118,9 +136,25 @@ protected override void GetGui()
GUI.enabled = enabled;
}

private void CallFBLogin()
private void CallFBLogin(string enabled="enabled")
{
FB.LogInWithReadPermissions(new List<string>() { "public_profile", "email", "user_friends" }, this.HandleResult);
List<string> scopes = new List<string>();
scopes.Add("public_profile");
if(enabled=="test+friends")
{
scopes.Add("user_friends");
}


if(enabled=="enabled")
{
FB.Mobile.LoginWithTrackingPreference(LoginTracking.ENABLED, scopes, "classic_nonce123", this.HandleResult);
}
else
{
FB.Mobile.LoginWithTrackingPreference(LoginTracking.LIMITED, scopes, "limited_nonce123", this.HandleLimitedLoginResult);
}

}

private void CallFBLoginForPublish()
Expand Down