2

当我使用 Settings/facebook 中设置的帐户在 ios 6 设备中运行 fb.login() 时,我得到以下信息

operation couldn't be completed (com.facebook.sdk error 2)

在 ios 5 中,该应用程序运行良好,问题是本机登录

请帮忙 !这是我的代码

这是脸书初始化

   this.appId = appId;
    var me = this;

    document.addEventListener('deviceready', function() {
                                  try {

                                  FB.init({ appId: "294003447379425", status: true, cookie: true, nativeInterface: CDV.FB, useCachedDialogs: false });

                                  } catch (e) {
                                  console.log(e);
                                  }
                                  }, false);


    if (!this.appId) {
        Ext.Logger.error('No Facebook Application ID set.');
        return;
    }



    var me = this;
    me.hasCheckedStatus = false;


    FB.Event.subscribe('auth.logout', function() {
        // This event can be fired as soon as the page loads which may cause undesired behaviour, so we wait
        // until after we've specifically checked the login status.
        if (me.hasCheckedStatus) {
            me.fireEvent('logout');
        }
    });

    // Get the user login status from Facebook.
    FB.getLoginStatus(function(response) {

        me.fireEvent('loginStatus');

        clearTimeout(me.fbLoginTimeout);
        me.hasCheckedStatus = true;

        if (response.status == 'connected') {
            me.fireEvent('connected');


        Ext.Viewport.add(Ext.create('CinePass.view.Main'));


        } else {
            me.fireEvent('unauthorized');
            console.log('noconectado');

            Ext.Viewport.add(Ext.create('CinePass.view.LoggedOut'));
        }
    });

    // We set a timeout in case there is no response from the Facebook `init` method. This often happens if the
    // Facebook application is incorrectly configured (for example if the browser URL does not match the one
    // configured on the Facebook app.)
    me.fbLoginTimeout = setTimeout(function() {
        me.fireEvent('loginStatus');
        me.fireEvent('exception', {
            type: 'timeout',
            msg: 'The request to Facebook timed out.'
        });
        Ext.Msg.alert('CinePass', 'Existe un problema con Facebook, se iniciará la aplicación sin conexión a Facebook.', Ext.emptyFn);
         Ext.Viewport.add(Ext.create('CinePass.view.Main'));
    }, me.fbTimeout);

这是登录

            FB.login(
                     function(response) {
                     if (response.session) {
                      alert(response.session);

                     } else {
                  alert(response.session);
                     }
                     },
                     { scope: "email,user_about_me,user_activities,user_birthday,user_hometown,user_interests,user_likes,user_location,friends_interests" }
                     );
4

1 回答 1

2

遇到同样的问题,我花了几天时间才弄清楚,原因有很多:

1)第一次启动应用,如果拒绝“你允许这个应用使用你的facebook权限”,你会得到这个错误,你需要做的是,去设置>通用> Facebook>转在您的应用程序上或转到设置 > 常规 > 重置 > 重置位置和隐私(这将重置并再次询问您“您是否允许此应用程序使用您的 Facebook 权限”以用于所有应用程序。

2)慢速/没有互联网会导致错误

3)再次创建您的证书,然后转到 build.phonegap.com,为 IOS 创建一个新密钥并更改 IOS 密钥(这对我有用,我不知道它是如何工作的,但确实如此,我注意到一个重要的应用程序文件我使用新的 IOS 密钥后大小增加)

4) 如果您的应用程序处于沙盒模式,并且您的 IOS 当前 Facebook 帐户不是应用程序测试员,您也会收到错误消息。我只是禁用沙盒模式并且它可以工作,确保您的 Facebook 应用设置具有正确的捆绑 ID,如果您的应用仍在开发中,请将 0 放入应用商店 ID。

于 2013-04-10T10:36:38.733 回答