Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Feb 26, 2018 at 05:13 AM by Ginxx009 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Ginxx009 · Nov 20, 2017 at 08:19 AM · androidunity 5facebook

Facebook SDK Session(UNITY)

I'm creating a LOGIN system using FACEBOOK SDK 7.4.0 version and Unity 5.6.3P2. It successfully gets the information i needed when i first login . I have 2 problems with the FACEBOOK SDK actually.

When i logout it successfully return to my landing menus. Now the problem occurs here because when i try to login again it doesn't work anymore it keeps on popping like this.

alt text 2.) When i login for the first time it successfully get the information i wanted then when i close my application and reopen it. I will need to click again the login button which is not to be like that. Its like no session on the FACEBOOK SDK.

Here's my code so far.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 //include for facebook namespace
 using Facebook.Unity;

 public class FBManager : MonoBehaviour {

 public GameObject LoggedIn;
 public GameObject LoggedOut;
 public GameObject ProfilePicture;
 public GameObject username;

 public Text Status;
 //Button for the Google Account
 public GameObject GoogleAccount; /*Just uses this for the setActive of the button */
 //Button for the Local Account    
 public GameObject LocalAccount; /*disable this*/
 //Button for the playstore
 public GameObject PlayStoreAccount; /*disable this*/

 void Awake(){
     FB.Init (OnSetInit, OnHideUnity);
 }

 void OnSetInit(){
     if (FB.IsLoggedIn) {
         Debug.Log ("FB is Logged in");
         Status.text = "FB is Logged In";
     } else {
         Debug.Log ("FB is not Logged in");
         Status.text = "FB is not Logged In";
     }
     DealWithFBMenus (FB.IsLoggedIn);
 }

 void OnHideUnity(bool isGameShown){
     if (!isGameShown) {
         Time.timeScale = 0;
     } else {
         Time.timeScale = 1;
     }
 }

 public void FbLogin(){
     List<string> permissions = new List<string> ();

     //ask for public profile
     permissions.Add("public_profile");

     FB.LogInWithReadPermissions (permissions, AuthCallBack);
 }

 public void FbLogout(){
     List<string> permission = new List<string> ();

     FB.LogOut ();
     //remove public Profile
     permission.Remove("public_profile");
     DealWithFBMenus (FB.IsLoggedIn);
     Debug.Log ("FB is Logged Out");
     Status.text = "FB is Logged Out";

 }

 void AuthCallBack(IResult result){
     if (result.Error != null) {
         Debug.Log (result.Error);

     } else {
         if (FB.IsLoggedIn) {
             Debug.Log ("FB is Logged in");
             Status.text = "FB is Logged In";
         } else {
             Debug.Log ("FB is not Logged in");
             Status.text = "FB is not Logged In";
         }
         DealWithFBMenus (FB.IsLoggedIn);
     }
 }

 void DealWithFBMenus(bool isLoggedIn){
     if (isLoggedIn) {
         LoggedIn.SetActive (true);
         LoggedOut.SetActive (false);
         GoogleAccount.SetActive (false);
         LocalAccount.SetActive (false);
         PlayStoreAccount.SetActive (false);
         FB.API ("/me?fields=first_name", HttpMethod.GET, DisplayUsername);
         FB.API ("/me/picture?type=square&height=128&width=128", HttpMethod.GET, DisplayProfilePic);
     } else {
         LoggedIn.SetActive (false);
         LoggedOut.SetActive (true);
         GoogleAccount.SetActive (true);
         LocalAccount.SetActive (true);
         PlayStoreAccount.SetActive (true);
     }
 }

 void DisplayUsername(IResult result){
     Text UserName = username.GetComponent<Text> ();

     if (result.Error == null) {
         UserName.text = "hi there " + result.ResultDictionary ["first_name"]; 
     } else {
         Debug.Log (result.Error);
     }
 }

 void DisplayProfilePic(IGraphResult result){
     Image ProfilePic = ProfilePicture.GetComponent<Image> ();
     if (result.Texture != null) {

         ProfilePic.sprite = Sprite.Create (result.Texture, new Rect (0, 0, 128, 128), new Vector2 ());

     } else {

         Destroy (ProfilePic.sprite);
     }
 }
 }


 


screenshot-2017-11-20-15-30-27-091.png (79.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

218 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem Integration Facebook with Unity 5 On Android 0 Answers

how to get facebook game request url? 2 Answers

unity Facebook For Android Error 0 Answers

Game Analytics & Facebook sdk android build error 1 Answer

D8: Program type already present: com.facebook.unity.Constants 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges