使用Ionic和Cordova在应用程序浏览器中使用$ authWithOAuthPopUp后,Angularfire $ onAuth无法触发

时间:2016-03-24 23:22:59

标签: angularjs cordova ionic-framework firebase angularfire

我正在开发一个Ionic应用程序,该应用程序使用Twitter登录通过OAuth弹出并从登录页面重定向到主仪表板。它在桌面上工作正常,但当编译为离子应用程序(在这种情况下为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');
});

2 个答案:

答案 0 :(得分:0)

正如@mhartington指出需要安装whitelist plugin并且根据此tutorial

将以下两行添加到config.xml中
<allow-intent href="*.firebaseio.com" />
<allow-intent href="auth.firebase.com" />

希望这可以帮助其他任何人用这个敲打砖墙!

答案 1 :(得分:0)

看起来您只需要添加白名单插件并允许访问firebase网址