Unable to retrieve access token for facebook on real device

前端 未结 3 2040
攒了一身酷
攒了一身酷 2020-12-09 12:24

I did Facebook integration in my project, everything is fine on emulator. When it comes to run on real device it is not working. I think the problem is Facebook access token

3条回答
  •  一个人的身影
    2020-12-09 12:43

    you can save access token on sharedReference when login as follow

    public void onComplete(Bundle values) 
    {
       SharedPreferences sp;
       Editor editor = sp.edit();
       editor.putString("access_token",fb.getAccessToken());
       editor.putLong("access_expires",fb.getAccessExpires());
       editor.commit();
    }
    

    and Check this onCreate Method as follow

    public void onCreate(Bundle savedInstanceState) 
    {           
           super.onCreate(savedInstanceState);
           setContentView(R.layout.activity_facebook_app);
            if(access_token != null){
                fb.setAccessToken(access_token);
            }
            if(expires != 0){
                fb.setAccessExpires(expires);
            }       
    }
    

提交回复
热议问题