2016-01-06 39 views
0

我在離子的firebase facebook彈出式登錄功能正常,但突然停止工作(當然,我正在修改應用程序,但我沒有碰到該服務)。該過程仍然適用於瀏覽器(當我使用離子服務時),但不運行在離子應用程序上。Firebase的facebook popup會彈出返回null

var auth = $fAuth(ref); 
    // login with Facebook 
    auth.$onAuth(function(authData){ // authData -> null 
    console.log("Auth..", authData); // Auth.. null 
    /* refresh user data on firebase and registering push */ 
    }); 
    auth.$authWithOAuthPopup("facebook").catch(function(error) { 
    console.log("Authentication failed:", error); 
    }); 

當它工作時,$ onAuth cb函數在authData變量中接收一個對象,其屬性如uid和facebook。

當我運行:

ref.authWithOAuthPopup("facebook",function(){console.log(arguments)}) 

或:

ref.authWithOAuthPopup("twitter",function(){console.log(arguments)}) 

回調函數永遠不會觸發。

我在$ ionicPlatform.ready事件上運行auth進程。 我已經卸載並重新安裝了應用程序,並清除了應用程序數據。

謝謝!

回答

0

你確定它不會着火嗎?

一個回調函數,將在驗證完成時調用。失敗時,第一個參數將是一個Error對象,指示失敗,並帶有機器可讀的代碼屬性。 成功時,第一個參數爲空,第二個參數爲包含字段uid(唯一用戶標識),提供者(標識提供者的字符串),auth(認證令牌負載)和過期(到期時間從Unix時代開始以秒計) - 以及更多,取決於用於認證的提供商。

你沒有把參數放在那裏。 我認爲它應該工作,如果你再試一次。 示例代碼火力點:

ref.authWithOAuthPopup("facebook", function(error, authData) { 
//           ^^^^^ ^^^^^^^^ 
    if (error) { 
    console.log("Login Failed!", error); 
    } else { 
    console.log("Authenticated successfully with payload:", authData); 
    } 
}); 
+0

哦,只是爲了讓總之,「參數」是傳遞給函數的所有參數數組的調用時,我想你的建議太代碼,它不火:/ – user3100334

+0

正如我所說,authWithOAuthPopuo的回調甚至不會觸發。我在onAuth的回調中收到null。 ref.onAuth(function(data){/ * here data is null * /}); – user3100334

+0

函數的第一個參數是錯誤對象。 **第二**是實際數據。如果第一個參數爲空,則表示它已成功(/沒有錯誤)。 'ref.onAuth(function(error,data){/ * error將爲null,數據應該是auth-object * /});' – nicfo