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 /
avatar image
0
Question by greaneagle · Dec 02, 2015 at 03:40 PM · androidunity5facebooksdk

Facebook SDK v7.2 login not working when on android

Hello, so here is my problem. I am using tthe newest Unity and Facebook SDk. What I want to do is have a facebook login on the menu screen of my game and a share button if the player is logged in.

I got it all to work just fine in the editor, the login with the token and share work like they should (I think) But when I bulild the app and put it on android, the game works fine, but when I click my login button, the Facebook window pops up like it should but it says "Error, you are not logged in"

Um.... well yeah, I am not logged in since I just pressed the login button. I cant figure this one out. Did anyone have a similar problem with the new SDK? If not I will post my code of my login and shar scripts and would apreciate any help :)

Thank you!

Comment
Add comment · Show 1
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
avatar image zzzzzz789 · Dec 02, 2015 at 05:06 PM 0
Share

I recommend you start with the 'Getting Started' guides to get up and running with the SD$$anonymous$$ sample on Android: https://developers.facebook.com/docs/unity/gettingstarted https://developers.facebook.com/docs/unity/getting-started/android https://developers.facebook.com/docs/unity/examples

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by phil_me_up · Dec 02, 2015 at 06:42 PM

It sounds like you might be trying to share before you're logged in (i.e. an issue with your logic). If you post the code you use to decide what action to take when the button is pressed it will help find the problem.

Comment
Add comment · Share
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
avatar image
0

Answer by greaneagle · Dec 02, 2015 at 09:15 PM

phill_me_up I dont know why but I couldnt reply to your anwser so my reply is here.

Nope, that is not it, I always check if its logged in before doing anything. Also thie error apears when I click the button that only does the login and no sharing. But thank you for your reply.

I will add my code here. Please take a look and I am sorry if it's just a noobish mistake I missed. This code is what I put together from the examples thata are on the Facebook developers website.

 using UnityEngine;
 using System.Collections;
 using Facebook.Unity;
 using System.Collections.Generic;
 
 public class FBscript : MonoBehaviour {
 
     // Include Facebook namespace
     public GameObject fbButton; // Assign in inspector
 
     // Awake function from Unity's MonoBehavior
     void Awake()
 {
     if (!FB.IsInitialized)
     {
         // Initialize the Facebook SDK
         FB.Init(InitCallback, OnHideUnity);
     }
     else
     {
         // Already initialized, signal an app activation App Event
         FB.ActivateApp();
     }
 
         
     
 }
 
      void Start() {
          if (FB.IsLoggedIn)
          {
              fbButton.SetActive(false);
          }
          else
          {
          fbButton.SetActive(true);
 
          }
 
 
      }
 
     private void InitCallback()
 {
     if (FB.IsInitialized)
     {
         // Signal an app activation App Event
         FB.ActivateApp();
         // Continue with Facebook SDK
         // ...
     }
     else
     {
         Debug.Log("Failed to Initialize the Facebook SDK");
     }
 }
 
 private void OnHideUnity(bool isGameShown)
 {
     if (!isGameShown)
     {
         // Pause the game - we will need to hide
         Time.timeScale = 0;
     }
     else
     {
         // Resume the game - we're getting focus again
         Time.timeScale = 1;
     }
 }
     public void loginFunction()
     {
         if (FB.IsLoggedIn)
         {
             Debug.Log("User already logged in!");
         }
         else
         {
           
             var perms = new List<string>() { "public_profile", "email", "user_friends" };
             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);
             // Print current access token's granted permissions
             foreach (string perm in aToken.Permissions)
             {
                 Debug.Log(perm);
             }
             fbButton.SetActive(false);
 
         }
         else
         {
             fbButton.SetActive(true);
             Debug.Log("User cancelled login");
         }
     }
 
 }
 

I have a button on the scene that runs the public function loginFunction() And that is all I can say about it.... I dont understand what goes wrong after that.

Comment
Add comment · Show 2 · Share
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
avatar image meat5000 ♦ · Dec 02, 2015 at 09:16 PM 0
Share

Answer must be less than 3000 characters to be converted to comment.

avatar image zzzzzz789 · Dec 03, 2015 at 12:09 AM 0
Share

Code looks fine, check your app configuration settings on the Facebook developer site. Also can you share more about the error you see (screenshot too).

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

integrate facebook with android 0 Answers

Facebook friends leaderboard (Android) 2 Answers

Facebook SDK 6.2.2 for Unity doesn't work on my Android Device 0 Answers

How to get a public profile permission facebook sdk 0 Answers

Facebook SDK IGraphResult is returning null values in Unity 2017.1.0f3 1 Answer


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