Facebook Connect works different on emulator/device, but not on Google Play

后端 未结 1 954
执笔经年
执笔经年 2021-01-16 14:39

I\'m getting a weird facebook connect behavior in my app. If I use it in emulator, the calls for facebook.request (to retrieve user data) and facebook.dialog (to post on wal

相关标签:
1条回答
  • 2021-01-16 15:16

    Facebook Connect is SSO flow, and when it is done onActivityResult is called back. you should handle the response in there

    simple example

    @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
    
    if (requestCode == AppContext.FACEBOOK_SSO_ACTIVITY_CODE) {
    
                // Successfully redirected.
                if (resultCode == Activity.RESULT_OK) {
    
                        // Check OAuth 2.0/2.10 error code.
                        String error = data.getStringExtra("error");
                        if (error == null) {
                            error = data.getStringExtra("error_type");
                        }
                        else {// SSO successful
                            String access_token = data.getStringExtra("access_token");
                            // from here on, you can do whatever you need
                         }
          }
    }
    

    on the other hand, I suggest two implement both options (sso and oauth as fallback). here is an example implementation for both Facebook SSO and OAuth; https://github.com/wareninja/generic-oauth2-login-for-android

    0 讨论(0)
提交回复
热议问题