trouble integrating facebook into a unity android project - android

I've been trying to integrate facebook into my project and I've successfully managed to do just that with the help of some online tutorials however I do have one persisting problem...
The code is set to pause the game using
Time.timescale = 0; when a facebook window is up and to resume play using Time.timescale = 1; when it's not
but that just doesn't happen, and the function that pauses the game never gets called...
Here's the code :
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
public class FBHolder : MonoBehaviour {
public GameObject UIFBIsLoggedIn;
public GameObject UIFBNotLoggedIn;
public GameObject UIFBAvatar;
public GameObject UIFBUserName;
public GameObject ScoreEntryPanel;
public GameObject ScoreScrollList;
private List<object> scoreslist = null;
private Dictionary<string, string> profile = null;
void Awake()
{
FB.Init (SetInit, onHideUnity);
}
private void SetInit()
{
Debug.Log ("FB Init Done");
if(FB.IsLoggedIn)
{
Debug.Log ("FB Logged In");
managefbmenus(true);
}
else
{
managefbmenus(false);
}
}
private void onHideUnity(bool isGameShown)
{
if(!isGameShown)
{
Debug.Log ("Pause Game");
Time.timeScale = 0;
}
else
{
Time.timeScale = 1;
}
}
public void FBLogin()
{
FB.Login ("email,publish_actions", Authcallback);
}
void Authcallback(FBResult result)
{
if(FB.IsLoggedIn)
{
Debug.Log ("FB Login Worked");
managefbmenus(true);
}
else
{
Debug.Log ("FB Login Failed");
managefbmenus(false);
}
}
void managefbmenus(bool isLoggedIn)
{
if(isLoggedIn)
{
UIFBIsLoggedIn.SetActive(true);
UIFBNotLoggedIn.SetActive(false);
SetScore();
//Get profile picture
FB.API(Util.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, DealWithProfilePicture);
FB.API("/me?fields=id,first_name", Facebook.HttpMethod.GET,DealwithUserName);
//Get username
}
if(!isLoggedIn)
{
UIFBIsLoggedIn.SetActive(false);
UIFBNotLoggedIn.SetActive(true);
}
}
void DealWithProfilePicture(FBResult result)
{
if(result.Error != null)
{
Debug.Log ("Problem getting profile picture");
FB.API(Util.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, DealWithProfilePicture);
return;
}
Image UserAvatar = UIFBAvatar.GetComponent<Image> ();
UserAvatar.sprite = Sprite.Create (result.Texture, new Rect(0, 0, 128, 128), new Vector2(0, 0));
}
void DealwithUserName(FBResult result)
{
if(result.Error != null)
{
Debug.Log ("Problem getting username");
FB.API("/me?fields=id,first_name", Facebook.HttpMethod.GET,DealwithUserName);
return;
}
profile = Util.DeserializeJSONProfile(result.Text);
Text UserMsg = UIFBUserName.GetComponent<Text>();
UserMsg.text = "Hello, " + profile ["first_name"];
}
Any ideas on what could be causing this issue?
BTW: I'm using unity 5.

I guess you don't need to pause your game while Facebook UI is displayed. you can just call it as:
FB.Init(SetInit);

Related

Unity, Facebook SDK, in Android build the app crashes

I am integrating Unity Facebook SDK to a project, right now I am making a log-in system. I have written a script, attached it to an object on a scene, created a button, added the FbLogin method as a listener of OnClick UnityEvent of my button and built an app for Android. Also I have pasted all the needed keys and tokens.
using System.Collections.Generic;
using UnityEngine;
using Facebook.Unity;
class FacebookLoginSystem
{
private void Awake()
{
FB.Init(SetInit, OnHideUnity);
}
void SetInit()
{
if (FB.IsLoggedIn)
{
Debug.Log("Logged in Successfuly!");
}
else
{
Debug.Log("FB is not loggid in");
}
}
void OnHideUnity(bool isGameShown)
{
if (isGameShown)
{
Time.timeScale = 1;
}
else
{
Time.timeScale = 0;
}
}
public void FbLogin()
{
List<string> permessions = new List<string>();
permessions.Add("public_profile");
FB.LogInWithReadPermissions(permessions, AuthCallResult);
}
private void AuthCallResult(ILoginResult result)
{
if (result.Error != null)
{
Debug.Log(result.Error);
}
else
{
if (FB.IsLoggedIn)
{
Debug.Log("FB logged in");
Debug.Log(result.RawResult);
FB.API("/me?fields=first_name", HttpMethod.GET, callbackData);
}
else
{
Debug.Log("Login Failed!");
}
}
}
}
But when I press the button in my build, I get this. ("Something went wrong, we are working on it...")
Tell me, please, why does it happen?
This happens when I press the button
UPD:
I have replaced the methods FbLogin and AuthCallback with these versions. Also I added a serialized field TextForLogging to see my logs in Build, and it tells me that "User cancelled login".
public void FbLogin()
{
var perms = new List<string>() { "public_profile", "email" };
FB.LogInWithReadPermissions(perms, AuthCallback);
}
private void AuthCallback(ILoginResult result)
{
if (FB.IsLoggedIn)
{
// AccessToken class will have session details
var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;
// Print current access token's User ID
Debug.Log(aToken.UserId);
TextForLogging.text += $"\n{aToken.UserId}";
// Print current access token's granted permissions
foreach (string perm in aToken.Permissions)
{
Debug.Log(perm);
TextForLogging.text += $"\n{perm}";
}
FB.API("/me?fields=first_name", HttpMethod.GET, callbackData);
}
else
{
Debug.Log("User cancelled login");
TextForLogging.text += "\nUser cancelled login";
}
}

Does Google Play Services in Unity, store data somewhere inside Unity?

I need help with Google Play Games plugin in unity.
My game have some scenes (1 - menu, 5 - game scenes). I downloaded plugin and write code, that initializing play games and sign user in. After this, I'm using firebase initialization and login with Play Games.
Everything works fine, when I'm starting my game (I checked logs with logcat and it shows my login and message that sign in was successful both for firebase and play games services). My script that controls firebase and google play service contains DontDestroyOnLoad and it Destroys duplicates.
When I'm returning from game scene to menu again, logcat saying that that was error and it can't login. I can press log out (on button) and log in again, and it will be good.
So, can someone answer me question, should my PlayServices walk to other scenes with DontDestroyOnLoad, or it stores data somewhere in Unity libraries (SocialPlatform)? I can't submit achievements on game scene and I can't doing other things with this...
Thanks
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using Firebase;
using Firebase.Auth;
using Firebase.Analytics;
using UnityEngine.SocialPlatforms;
using UnityEngine.SceneManagement;
using TMPro;
public class GooglePlayServices : MonoBehaviour
{
private GPG_CloudSaveSystem cloudSaveSystem = new GPG_CloudSaveSystem();
private string authCode;
private bool firebaseInitialized;
DependencyStatus dependencyStatus = DependencyStatus.UnavailableOther;
public static GooglePlayServices instance;
private bool isFirebaseLogged, isPlayGamesLogged;
FirebaseAuth auth;
FirebaseUser user;
private string userNametest, userNameId;
void Awake()
{
if (instance == null)
{
instance = this;
DontDestroyOnLoad(this.gameObject);
}
else
{
DestroyImmediate(gameObject);
}
auth = FirebaseAuth.DefaultInstance;
PlayGamesClientConfiguration config = new
PlayGamesClientConfiguration.Builder()
.EnableSavedGames()
.RequestServerAuthCode(false)
.Build();
// Enable debugging output (recommended)
PlayGamesPlatform.DebugLogEnabled = true;
// Initialize and activate the platform
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
if (!isPlayGamesLogged)
{
PlayGamesPlatform.Instance.Authenticate(SignInCallback, false);
}
}
private void Start()
{
Debug.Log("User name: " + userNametest + " | User ID: " + userNameId);
}
void LoginFirebase()
{
if (Social.localUser.authenticated)
{
authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
}
else
{
PlayGamesPlatform.Instance.Authenticate(SignInCallback, false);
authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
}
//FirebaseAuth auth = FirebaseAuth.DefaultInstance;
FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
// Set the user's sign up method.
FirebaseAnalytics.SetUserProperty(
FirebaseAnalytics.UserPropertySignUpMethod,
"PlayGames");
Credential credential = PlayGamesAuthProvider.GetCredential(authCode);
auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
{
if (task.IsCanceled)
{
Debug.LogError("SignInWithCredentialAsync was canceled.");
return;
}
if (task.IsFaulted)
{
Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
return;
}
FirebaseUser newUser = task.Result;
userNametest = newUser.DisplayName;
userNameId = newUser.UserId;
Debug.LogFormat("User signed in successfully: {0} ({1})",
newUser.DisplayName, newUser.UserId);
// Set the user ID.
FirebaseAnalytics.SetUserId(newUser.UserId);
isFirebaseLogged = true;
});
// Set default session duration values.
FirebaseAnalytics.SetMinimumSessionDuration(new TimeSpan(0, 0, 10));
FirebaseAnalytics.SetSessionTimeoutDuration(new TimeSpan(0, 30, 0));
firebaseInitialized = true;
}
public void EventLevelFinished(int levelNumber)
{
string eventLog = "Level_finished_" + (levelNumber + 1).ToString();
switch (levelNumber)
{
case 2:
{
FirebaseAnalytics.LogEvent(eventLog);
break;
}
case 9:
{
FirebaseAnalytics.LogEvent(eventLog);
break;
}
case 19:
{
FirebaseAnalytics.LogEvent(eventLog);
break;
}
case 29:
{
FirebaseAnalytics.LogEvent(eventLog);
break;
}
case 39:
{
FirebaseAnalytics.LogEvent(eventLog);
break;
}
case 49:
{
FirebaseAnalytics.LogEvent(eventLog);
break;
}
case 59:
{
FirebaseAnalytics.LogEvent(eventLog);
break;
}
}
}
public void EventLogCustomEvent(string log)
{
FirebaseAnalytics.LogEvent(log);
}
public string GetFirebaseUser()
{
return user.DisplayName + " | " + user.UserId;
}
public void SaveToCloud()
{
JsonToCloud.instance.BuildSaveString();
cloudSaveSystem.saveString = Prefs.CloudSaveString;
cloudSaveSystem.SaveToCloud();
}
public void LoadFromCloud()
{
cloudSaveSystem.LoadFromCloud();
Prefs.CloudSaveString = cloudSaveSystem.saveString;
JsonToCloud.instance.StringToData();
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
public void ShowSavedGames()
{
cloudSaveSystem.showUI();
}
public void AnalyticsLogin()
{
FirebaseAnalytics.LogEvent(FirebaseAnalytics.EventLogin);
}
public void AnalyticsProgress()
{
FirebaseAnalytics.LogEvent("progress", "percent", 0.4f);
}
void InitializeFirebase()
{
FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
// Set the user's sign up method.
FirebaseAnalytics.SetUserProperty(
FirebaseAnalytics.UserPropertySignUpMethod,
"PlayGames");
// Set the user ID.
FirebaseAnalytics.SetUserId("uber_user_510");
// Set default session duration values.
FirebaseAnalytics.SetMinimumSessionDuration(new TimeSpan(0, 0, 10));
FirebaseAnalytics.SetSessionTimeoutDuration(new TimeSpan(0, 30, 0));
firebaseInitialized = true;
}
public void ShowAchievements()
{
if (PlayGamesPlatform.Instance.localUser.authenticated)
{
PlayGamesPlatform.Instance.ShowAchievementsUI();
}
else
{
Debug.Log("Cannot show Achievements, not logged in");
}
}
public void SignIn()
{
if (!PlayGamesPlatform.Instance.localUser.authenticated)
{
// Sign in with Play Game Services, showing the consent dialog
// by setting the second parameter to isSilent=false.
PlayGamesPlatform.Instance.Authenticate(SignInCallback, false);
}
else
{
// Sign out of play games
PlayGamesPlatform.Instance.SignOut();
}
AnalyticsLogin();
}
public void SignInCallback(bool success)
{
if (success)
{
isPlayGamesLogged = true;
Debug.Log("(Lollygagger) Signed in!");
authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
////////////////////////////////
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
{
dependencyStatus = task.Result;
if (dependencyStatus == DependencyStatus.Available)
{
if (!isFirebaseLogged)
{
LoginFirebase();
}
}
else
{
Debug.LogError(
"Could not resolve all Firebase dependencies: " + dependencyStatus);
}
});
/////////////////////////////////////////
}
else
{
Debug.Log("(Lollygagger) Sign-in failed...");
}
}
}
One guy on github issues answered me, that there is no need to use DontDestroyOnLoad, just use once at main scene and that's all

Facebook logins only in Editor or Development Build(Unity 3D)

I have a problem with the Facebook SDK. It works fine in Editor and in apk(if i check the development build option in Unity), but on release build it doesn't work.
Here is my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Facebook.Unity;
using UnityEngine.UI;
using Facebook.MiniJSON;
public class FBManager : MonoBehaviour {
[SerializeField]private Text FBErrorText;
public RawImage FBProfilePicture;
public Image DefaultAvatar;
public Text UsernameText;
public Text WelcomeMessage;
public Button FacebookButton;
private Color fbProfilePictureColor;
private Color defaultAvatarColor;
private string getData;
private string FBUserName;
void Awake()
{
if (!FB.IsInitialized)
{ FBErrorText.text = "fb not ini, initializing";
FB.Init(InitCallBack, OnHideUnity);
FBErrorText.text = "called fb.init";
}
else
{ FBErrorText.text += "initialized";
FB.ActivateApp();
FBErrorText.text += "called fb.activateApp";
}
fbProfilePictureColor = FBProfilePicture.color;
defaultAvatarColor = DefaultAvatar.color;
fbProfilePictureColor.a = 0f;
FBProfilePicture.color = fbProfilePictureColor;
}
void Start()
{
//StartCoroutine (FbLoginWait ());
}
IEnumerator FbLoginWait()
{
yield return new WaitUntil (()=> FB.IsInitialized);
FBLogin ();
}
//auto logare
private void InitCallBack()
{
if (FB.IsInitialized)
{
//UsernameText.text = "Initialized FB SDK";
FBErrorText.text = "fb is initialized";
FB.ActivateApp ();
FBErrorText.text = "fb activated app";
}
else
{
FBErrorText.text = "Failed to initialize the Facebook SDK";
Debug.Log ("Failed to initialize the Facebook SDK");
}
}
private void OnHideUnity(bool isGameShown)
{
if (!isGameShown)
{
Time.timeScale = 0;
}
else
{
Time.timeScale = 1;
}
}
private void HandleLoginFB(bool IsLogged)
{
if (IsLogged)
{
FBErrorText.text = "user logged in";
Debug.Log ("User logged in");
}
else
{
FBErrorText.text = "user cancelled login";
Debug.Log ("User cancelled login");
}
}
private void AuthCallback(IResult result)
{
FBErrorText.text = "called authcallback";
HandleLoginFB (FB.IsLoggedIn);
FBErrorText.text = "handling fb";
if (FB.IsLoggedIn)
{
var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;
Debug.Log (aToken.UserId);
foreach (string perm in aToken.Permissions) {
Debug.Log (perm);
}
FB.API ("/me/picture?type=square&height=50&width=50", HttpMethod.GET, UpdateProfileImage);
FB.API ("me?fields=name", HttpMethod.GET, GetUsername);
FBErrorText.text = "fb is logged in";
}
else
{
FBErrorText.text = "fb is not logged in";
}
}
public void FBLogin()
{
FBErrorText.text = "called fblogin";
List<string> perms = new List<string> () { "public_profile, email", "user_friends" };
FBErrorText.text = "created perms";
FB.LogInWithReadPermissions (perms, AuthCallback);
FBErrorText.text = "ended fblogin";
}
private void UpdateProfileImage(IGraphResult result)
{
if(result.Texture != null)
{
FBProfilePicture.texture = result.Texture;
defaultAvatarColor.a = 0f;
fbProfilePictureColor.a = 255f;
DefaultAvatar.color = defaultAvatarColor;
FBProfilePicture.color = fbProfilePictureColor;
}
}
private void GetUsername(IGraphResult result)
{
FBUserName = result.ResultDictionary ["name"].ToString ();
UsernameText.text = FBUserName;
WelcomeMessage.text = FBUserName + "'s NET WORTH";
}
}
(or the same code here https://hastebin.com/osatiketij.cs)
The last error text on the screen which appears is : "created perms", so right before the FB.LogInWithReadPermissions method is called, no error text appears after that, but no login also.
Any idea what it might be ?
For everyone coming to this thread : how I manage to fix this was by using Android Studio to see with the Logcat why it doesn't work, and it was "missing" a class. For anyone coming here, I fixed it by adding "-keep class com.facebook.** {*;}" to my proguard-user file.

Show 3dmodel after tracking lost metaio sdk

I am using metaio sdk 6.0.2. i am working on metaio INSTANT_2D_GRAVITY tracking and was able to display 3d model. I want to display same 3d model when tracking is lost.but I am failing to do so. I tried by adding trackingValuesVector in onTrackingEvent of MetaioSDKCallbackHandler with no success. can anyone tell me where am I going wrong?
private TrackingValues mTrackingValues;// declared globally
private IGeometry mModel; // declared globally
private boolean mPreview=true;// declared globally
// start INSTANT_2D_GRAVITY tracking
public void onTakePicture(View v)
{
captureTrackingValues = true;
metaioSDK.startInstantTracking("INSTANT_2D_GRAVITY", new File(""), mPreview);
mPreview = !mPreview;
}
final class MetaioSDKCallbackHandler extends IMetaioSDKCallback
{
#Override
public void onInstantTrackingEvent(final boolean success,final File filePath) {
super.onInstantTrackingEvent(success, filePath);
if(mSurfaceView != null)
{
mSurfaceView.queueEvent(new Runnable() {
#Override
public void run() {
if(success)
{
if(captureTrackingValues == true)
{
metaioSDK.setTrackingConfiguration(filePath);
Log.i("Tracking value success","good");
}
}
else
{
Log.i("Tracking value failure","bad");
}
}
});
}
}
#Override
public void onTrackingEvent(TrackingValuesVector trackingValuesVector) {
super.onTrackingEvent(trackingValuesVector);
if (!trackingValuesVector.isEmpty())
{
for(int i =0;i< trackingValuesVector.size();i++)
{
if(trackingValuesVector.get(i).isTrackingState() && mModel!=null)
{
mTrackingValues = metaioSDK.getTrackingValues(i);
mModel.setCoordinateSystemID(trackingValuesVector.get(i).getCoordinateSystemID());
}
else {
if(mModel!= null && mTrackingValues != null) {
metaioSDK.setCosOffset(1, mTrackingValues);
//mChairModel.setCoordinateSystemID(0);
Log.e("TestAR","isTrackingState is null");
}
}
}
}
else{
if(mModel!= null && mTrackingValues != null) {
metaioSDK.setCosOffset(1, mTrackingValues);
//mModel.setCoordinateSystemID(0);
Log.e("TestAR","trackingValuesVector is null");
}
}
}
}
loading 3d model:
private void loadModel()
{
if (mSurfaceView != null) {
mSurfaceView.queueEvent(new Runnable() {
#Override
public void run() {
File chairModel = AssetsManager.getAssetPathAsFile(getApplicationContext(),"chair.obj");
if (chairModel != null) {
mModel = metaioSDK.createGeometry(chairModel);
mModel.setScale(3f);
mModel.setTranslation(new Vector3d(0f,0f,-60f));
mGestureHandler.addObject(mModel, 1);
mModel.setRotation(new Rotation(0f, 0.5f, 0f));
mModel.setCoordinateSystemID(1);
}
}
});
}
else
{
Log.e("exception", "msurfaceview is null");
}
}
I see that you also tried setting the model to COS 0. This should actually work, if the tracking is lost.
If you do not see the model, you would have to play around with the scale value (i.e. set a low value like 0.01) and with the Z translation value. Set a negative Z value in order to move the model away from the camera clipping plane.

Facebook SDK on Unity cant get anything except first_name

so here is my code for connecting and getting the values:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Facebook;
using SmartLocalization;
public class mainMenuFacebook : MonoBehaviour {
public string FBname;
public string FBsurname;
Dictionary<string, string> profile = new Dictionary<string, string>();
// Use this for initialization
void OnMouseDown()
{
FB.Login("publish_actions,public_profile", LoginCallback); // logine tıklama
}
void Awake() {
FB.Init(SetInit, OnHideUnity); //facebook başlangıcı
}
private void SetInit()
{
if (FB.IsLoggedIn)
{
// Util.Log("Already logged in");
OnLoggedIn();
}
}
private void OnHideUnity(bool isGameShown)
{
if (!isGameShown)
{
// pause the game - we will need to hide
Time.timeScale = 0;
}
else
{
// start the game back up - we're getting focus again
Time.timeScale = 1;
}
}
void LoginCallback(FBResult result)
{
Util.Log("LoginCallback");
if (FB.IsLoggedIn)
{ gameObject.guiTexture.enabled = false;
OnLoggedIn();
}
}
void OnLoggedIn()
{
FB.API("/me?fields=first_name,last_name,email", Facebook.HttpMethod.GET, APICallback); // adını ve idyi çekiyoruz.
}
void APICallback(FBResult result)
{
if (result.Error != null)
{
// Let's just try again
// FB.API("/me?fields=id,first_name,last_name,email,friends.limit(100).fields(first_name,last_name,id)", Facebook.HttpMethod.GET, APICallback);
return;
}
Debug.Log(result.Text);
profile = Util.DeserializeJSONProfile(result.Text);
FBname = profile["first_name"];
FBsurname = profile["last_name"]; // **IT GIVES ERROR**
Debug.Log(FBsurname + " " + FBname);
//PlayerPrefs.SetString("surname",profile["last_name"]);
//PlayerPrefs.SetString("email",profile["email"]);
gameObject.guiTexture.enabled = false;
GameObject.Find("Wellcome").guiText.enabled = true;
GameObject.Find("Wellcome").guiText.text = LanguageManager.Instance.GetTextValue("menu.hosgeldin") + " <b><color=#ffa500ff>" + FBname + "</color></b>, <i>" + LanguageManager.Instance.GetTextValue("menu.cikis") +"</i>";
PlayerPrefs.SetString("name",FBname);
}
}
when i only try to get first_name everything is okay. But i need to get last_name and email too. I think i cant serialize because when i try to Debug.Log(profile.Count); it shows 1.
How can i fix it?
Given error is:
KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[System.String,System.String].get_Item (System.String key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
mainMenuFacebook.APICallback (.FBResult result) (at Assets/Scripts/mainMenuFacebook.cs:84)
Facebook.AsyncRequestString+<Start>c__Iterator0.MoveNext ()
Try this:
public void OnMouseDown()
{
List<string> permissions = new List<string>() { "public_profile", "email" };
FB.LogInWithReadPermissions(permissions,AuthCallback);
Debug.Log("Facebook Login");
}
In AuthCallback: if user logs in successfully, get info from FB api.
private void AuthCallback(ILoginResult result)
{
if(FB.IsLoggedIn)
{
GetInfo();
}
else
{
Debug.Log("User cancelled login");
}
}
FB API returns json result, so you will need FacebookUser class to deserialize it.
class FacebookUser
{
public string id;
public string first_name;
public string last_name;
public string email;
}
public void GetInfo()
{
FB.API("/me?fields=id,first_name,last_name,email", HttpMethod.GET, result =>
{
if(result.Error != null)
{
Debug.Log("Result error");
}
var facebookUser = Newtonsoft.Json.JsonConvert.DeserializeObject<FacebookUser>(result.RawResult);
Debug.Log(" facebook id - " + facebookUser.id);
Debug.Log(" facebook first name - " + facebookUser.first_name);
Debug.Log(" facebook last name - " + facebookUser.last_name);
Debug.Log(" facebook email - " + facebookUser.email);
});
}
NOTE: You should have Email permission from facebook to access it.
Check it in Graph API Explorer

Categories

Resources