【发布时间】:2016-03-24 23:22:59
【问题描述】:
我正在开发一个 Ionic 应用程序,该应用程序通过 OAuth 弹出窗口使用 Twitter 登录,并从登录页面重定向到主仪表板。它在桌面上运行良好,但是当编译为离子应用程序(在本例中为 Android)时,登录窗口打开,重定向回应用程序,但随后什么也没有发生 - 这两个功能都没有(重定向到仪表板页面,并创建一个新用户)开火。
我已经阅读了几乎所有类似的问题和教程,只是找不到问题。我已经在应用程序浏览器中安装了 Cordova 来处理弹出窗口,并且我尝试了回调函数、$timeouts、$onAuth 观看 - 所有这些都可以在浏览器和 ionic 提供的浏览器内模拟器中完美运行,但不是全部编译到手机上的应用程序时。
非常感谢任何帮助。
我的控制器中的当前代码:
$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 我真的爱你。在我阅读的所有许多许多教程/问题中,只有one 提到了白名单,它被描述为可选的。甚至该指南的更新版本根本没有提及它。非常感谢!我会将信息作为答案放入,以便其他人找到解决方案
标签: angularjs cordova ionic-framework firebase angularfire