2016-03-24 22 views
0

我正在使用通过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'); 
}); 
+0

你是否在控制台中收到错误代码?我收到一个错误,所以我也会检查你的控制台。 – mhartington

+1

在我的情况下,我犯了一个错误,没有安装白名单插件。 我有一个示例应用程序,你可以在这里参考 – mhartington

+0

@mhartington我真的爱你。在我阅读的许多许多教程/问题中,只有[一个](https://www.firebase.com/docs/web/libraries/ionic/guide.html#section-user-authentication)提到了白名单,它是有些被描述为可选的。甚至有一个该指南的更新版本,根本没有提及它。非常感谢!我会将这些信息作为答案,以便其他人可以找到解决方案 –

回答

0

由于@mhartington指出需要whitelist plugin安装和以下两行添加到config.xml按本tutorial

<allow-intent href="*.firebaseio.com" /> 
<allow-intent href="auth.firebase.com" /> 

希望这可以帮助任何人用这个撞砖头墙!

0

看起来你只需要添加白名单插件并允许访问火力基地网址

相关问题