且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

某些设备上的Facebook登录失败

更新时间:2023-10-20 13:12:46

您的股票应用程序与SDK。所以,如果你不想uninsstall股票HTC应用程序,仍然使用SDK 3.0我认为你***的打赌,而不修改sdk的源代码将是禁用SSO和登录只能通过webview。

There is certainly a conflict between your stock app and the SDK. So if you don't want to uninnstall the stock HTC app and still use the SDK 3.0 I think your best bet without modying the source code of the sdk would be to disable SSO and login only through webview.

每次尝试打开新会话时,可以通过添加SessionLoginBehavior.SUPRESS_SSO轻松完成此操作。以下是从Facebook SDK中的SessionLoginSample(LoginUsingActivityActivity)中更改的示例,以显示如何处理:

This can easily be done by adding the SessionLoginBehavior.SUPRESS_SSO everytime you try to open a new session. Here is a sample I changed from the SessionLoginSample (LoginUsingActivityActivity) from the Facebook SDK to show you what to do :

@Override
public void onCreate(Bundle savedInstanceState) {
    ...
    Session session = Session.getActiveSession();
    if (session == null) {
        if (savedInstanceState != null) {
            session = Session.restoreSession(this, null, statusCallback, savedInstanceState);
        }
        if (session == null) {
            session = new Session(this);
        }
        Session.setActiveSession(session);

        //add the check, for if session is opened
        if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED) || !session.getState().isOpened()) {
            //Add the suppress SSO behavior to force webview auth dialog to popup
            session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback).setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO));
        }
    }
  ...
}
//then put your code in the statusCallback method or keep it in the session state change listener

否则,如果您不介意更改Facebook sdk代码,您应该检查这个出来

Otherwise if you don't mind changing the facebook sdk code, you should check this out