Android: How can I force a facebook auth by mobile

2020-03-05 03:20发布

I want to develop the android app with facebook authentication. But if the phone has facebook application in it, I cannot auth on my app, if not, it works well.

so, i want to force a facebook authentication by mobile web without facebook application.

Only if I use authorize(. , .)in application, it uses facebook app directly.

How can I fix this problem??

additionally, Hackbook(https://developers.facebook.com/docs/mobile/android/hackbook/) also doesn't work if I auth by facebook app. I cannot login on app.

/////comment

I found the answer by myself

Change the authorize function in facebook.java in facebook sdk.

public void authorize(Activity activity, final DialogListener listener) {
    authorize(activity, new String[] {}, FORCE_DIALOG_AUTH,
            listener);
}

/**
 * Authorize method that grants custom permissions.
 *
 * See authorize() below for @params.
 */
public void authorize(Activity activity, String[] permissions,
        final DialogListener listener) {
    authorize(activity, permissions, FORCE_DIALOG_AUTH, listener);
}

now it works!

1条回答
家丑人穷心不美
2楼-- · 2020-03-05 04:05

When you use Facebook SDK 3.0 and the login button the best way to force this is setting a LoginBehavior to the LoginButton. This can be done like this:

LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton);
authButton.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO);

Source: Android - Force Facebook connexion - Stack Overflow

查看更多
登录 后发表回答