2013-04-04 44 views
2

當我使用設置/ Facebook的設置好的帳戶在IOS 6設備運行的FB.login()我得到的在IOS 5應用以下錯誤的FB.login()的PhoneGap插件的Facebook

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

完美的作品,問題是本機登錄

請幫助!這是我的代碼

這是Facebook的初始化

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" } 
        ); 

回答

2

有同樣的問題,我花了幾天摸不着頭腦,也有一些原因:

1)第一次啓動你的應用程序,如果你否認「你允許這個應用程序使用你的Facebook權限」,你會得到這個錯誤,你需要做的是,去設置g> General> Facebook>打開你的應用程序或轉到設置>常規>重置>重置位置&隱私(這將重置並詢問你「你允許這個應用程序使用你的Facebook權限」再次爲所有應用程序。

2)慢/否互聯網可以導致錯誤

3)再次創建您的證書,並轉到build.phonegap.com,創造IOS新的密鑰並更改IOS鍵(這對我的作品,我不知道它是如何工作的,但它確實如此,我注意到在使用新的IOS密鑰後,應用程序文件大小增加了)

4)如果您的應用程序處於沙盒模式,並且您的IO​​S當前Facebook帳戶不是應用程序測試人員,你也會得到錯誤。我只是禁用沙盒模式,它的工作原理,確保您的Facebook應用程序設置具有正確的捆綁ID,如果您的應用程序仍在開發中,將0放到應用商店ID。

相關問題