how to log in to facebook in smartphone?

+1 vote
I am trying to use facebook leaderboard in my app referring to this.

http://blogs.shephertz.com/tag/unity3d-facebook-sdk/

In web, it asks me to enter 'User Access Token' for login everytime I run. I did and it works. (Should it be done automatically?)

In my smartphone(Galaxy note 2), it does not ask anything and no progress. it seems not to be able to login.

So my questions are

- How can I log in in the smartphone? Any sample codes of login procedure for smartphones?

- How can I post my score on the wall (my faceook account - for promotion) ? Any codes for this?

I am desperate in need of help. Thanks in advance for any help.
asked Feb 27, 2014 in App42 Cloud API-BaaS by David Kim (20 points)

1 Answer

0 votes
  1. Create an App on facebook and add your appId and name in facebook settings in unity editor.
  2. Create a android-keyhash for facebook android for more details: http://stackoverflow.com/questions/19243707/unity-android-using-facebook-sdk-missing-debug-android-keyhash
  3. Copy your class name and pakeage name from Android Build Facebook Settings in unity editor.
  4. Go to your facebook app settings and  Add plateform android.
  5. Put your class name and package name in android setting panel taken from step #3 and also paste your key-hash taken from step #2.
  6. In facebook settings you must open Single Sign On  and Deep Linking.
Note: In my case ganrate Key-hash from this command ---
 
keytool -exportcert -alias androiddebugkey -keystore C:\Users\Shashank\.android\debug.keystore | C:\OpenSSL-Win64\bin\openssl sha1 -binary | C:\OpenSSL-Win64\bin\openssl base64
 
And below my facebook app settings.

answered Feb 27, 2014 by sshukla480 (407 points)
Thank u for your answer.
Actually I did exactly what u said. It doesn't still work.
My source code is almost the same as the sample. Like I said, in web(I'm using Mac), it asks me to enter 'User Access Token' and it seems to go OK.
But, in smartphone, it can't login to facebook. It doesn't ask me to enter Access Token. It keeps trying to login and the phone stops.
In this case, what kind of mistakes do u think I have made ?
To login  with facebook in Unity facebook SDK
>> Call FB init
>> Call Your login method in init complete handler
>> After successfully login an access token getting from FB.AccessToken property
Make sure FB init function never call twice time in your app. For more details about FB init please see:
>> \Assets\scripts\Scripts\FBLeaderBoard.cs  at Line No. 148.  in sample
Sorry to keep bothering you.
So it is also supposed to be working properly in smartphone.
But it cannot log in to facebook.  My codes look like this....
--------------------------------------------------------------------
void OnGUI() {
    if (!FB.IsLoggedIn) {                                                                                                                
        if (GUILayout.Button("Connect", GUILayout.Height(30),GUILayout.Width(510)))         
        {
         CallFBInit();
        }
    }
           
    if (FB.IsLoggedIn) {
        ....
    }
    ....
}
------------------------------------------------------------------------
It keeps displaying "Connect" button, which means it cannot log in for some reasons.
Is there anything I should do more for smartphone login procedure?
Try this..

private void CallFBInit()
    {
        FB.Init(OnInitComplete, OnHideUnity);
    }
   
    private void OnInitComplete()
    {
        CallFBLogin();
    }
   
    private void OnHideUnity(bool isGameShown)
    {
        Debug.Log("Is game showing? " + isGameShown);
    }
   
    private void CallFBLogin()
    {
        FB.Login("email");
    }
The same as mine. T.T
Maybe not a coding problem...  I better try this from the scratch.
Thanks so much for your time anyway~
Good luck..

I think you miss something in facebook app settings like -- open Single Sign On  and Deep Linking like me
I didn't turn on Deep Linking first, and turned it on after hearing you.
But no luck.  Did u manage to get on facebook with this codes?
Sorry to ask. I am just sort of frustrated.
Yes it is quit frustrating and time consuming and that is the reason we are launching our own facebook login SDK soon which is easy to use and configure.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...