我正在使用通過OAuth彈出並使用Twitter登錄的Ionic應用程序,並將其從登錄頁面重定向到主儀表板。它在桌面上運行良好,但是當編譯爲離子應用程序(在這種情況下爲Android)時,登錄窗口打開,重定向迴應用程序,但沒有任何反應 - 兩個功能(重定向到儀表板頁面並創建新用戶)開火。
我已經閱讀了幾乎所有類似的問題和教程,只是找不到問題。我已經安裝了應用程序瀏覽器中的Cordova來處理彈出窗口,並且我嘗試了回調函數,$ timeouts,$ onAuth監視 - 所有工作都完美地在瀏覽器上以及瀏覽器中的模擬器中提供,但不是全部在編譯到手機上的應用程序時。
任何幫助是大規模讚賞。
我當前的代碼在我的控制器:
$scope.login = function() {
Auth.auth.$authWithOAuthRedirect('twitter').then(function(authData) {
// User successfully logged in
}).catch(function(error) {
if (error.code === "TRANSPORT_UNAVAILABLE") {
Auth.auth.$authWithOAuthPopup('twitter').then(function(authData) {
// User successfully logged in. We can log to the console
// since we’re using a popup here
console.log(authData);
});
} else {
// Another error occurred
console.log(error);
}
});
};
// Update profile and forward to homepage
Auth.auth.$onAuth(function(authData) {
console.log('Logged in as', authData.uid);
console.log(authData);
// Update/Create profile
Auth.new(authData);
// Forward to homepage
$state.go('tab.dash');
});
你是否在控制檯中收到錯誤代碼?我收到一個錯誤,所以我也會檢查你的控制檯。 – mhartington
在我的情況下,我犯了一個錯誤,沒有安裝白名單插件。 我有一個示例應用程序,你可以在這裏參考 – mhartington
@mhartington我真的愛你。在我閱讀的許多許多教程/問題中,只有[一個](https://www.firebase.com/docs/web/libraries/ionic/guide.html#section-user-authentication)提到了白名單,它是有些被描述爲可選的。甚至有一個該指南的更新版本,根本沒有提及它。非常感謝!我會將這些信息作爲答案,以便其他人可以找到解決方案 –