- Home /
Auto LogIn into face book
Hi , i connected my game with facebook API to share the result of the game, 2 months back it was working fine. when you click the button it ask for login then you logged into the face and sync your connection and share your result on Facebook.... and if you want to change your facebook account you remove the last account into the mobile account setting and add new one..... now the problem is when we add the account user id and password in the game it sync the account but when i off the game and remove my facebook account from the account setting and open my game , my previous account remain safe in the game and it share data with the last account we added before ........ what i am looking for is either a logout method properly or any other suggestion ... and i have used FB.Logout(); its not helping me out... here is my code
public class MainMenu : MonoBehaviour {
void Awake(){
// Initialize FB SDK
enabled = false;
FB.Init(SetInit);
}
private void SetInit()
{
enabled = true; // "enabled" is a property inherited from MonoBehaviour
}
void OnMouseDown()
{
if (!FB.IsLoggedIn) {
FB.Login ("email,publish_actions", LoginCallback);
}
else if (FB.IsLoggedIn) {
// OnLoggedIn();
onBragClicked ();
}
}
void LoginCallback(FBResult result)
{
// Util.Log("LoginCallback");
if (FB.IsLoggedIn)
{
OnLoggedIn();
}
}
void OnLoggedIn()
{
// Util.Log("Logged in. ID: " + FB.UserId);
FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
// onBragClicked ();
}
void APICallback(FBResult result)
{
// Util.Log("APICallback");
if (result.Error != null)
{
// Let's just try again
FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
return;
}
onBragClicked();
}
private void onBragClicked()
{
FB.Feed(
linkCaption: "I just Found My Love Result." +
"Click to Check out your's",
picture: "http://s16.postimg.org/r3fvqk5cl/jhj_3_2_2_2_2.jpg",
linkName: "LoveMeLoveMeNot",
link:"http://www.brokenfloorstudios.com/"
);
}
}
For future posts pull all of the comments out of your code. It really makes for difficult reading.
Basically you need a method to get compare the facebook ID stored on the phone with FB.userID. Then call FB.Logout if they are different, and prompt for another login.
I'm not familiar enough with mobile development to tell you how to get the ID stored in the phone.
@Bored$$anonymous$$ormon, how to access the facebook data stored on the phone?
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
facebook chat is hidden behind unity game 0 Answers
How to share high score(string)/game result data on facebook ...please any one help me ....:(. 2 Answers
"Facebook object not loaded yet" error 3 Answers
Get Facebook User name with Facebook sdk Unity android 3 Answers