如何在转到配置文件之前将用户发送到登录页面,以及如何将用户注销

时间:2016-09-02 22:08:21

标签: ios swift xcode login social-media

我已经完成了LogIn Page和Sign up Page工作正常,但它没有将用户重定向到LogIn Page。首先,用户需要登录才能重定向到配置文件页面,如果用户的电子邮件或密码错误,应用程序将不允许用户继续操作,我还需要有关注销用户的帮助。

检查我的导航流程here 请帮忙

我使用Swift laters版本编码

1 个答案:

答案 0 :(得分:0)

让我们从您的后端服务器获取,有一种方法可以检查某人当前是否已登录。它返回true或false。

现在,在您的移动应用中,您可以在appDelegate的didFinishLaunchingWithOptions中调用该方法来检查您是否有用户

var currentUser = User() 
//let's say that User class is where you established connection to your server.

if currentUser.isThereAnyUserLoggedIn(){
  // since this statement is true; then just show them your tabBar
 // give the tabBar an ID then initiate it from the storyboard  
} else {
     // which means there is no one
   // then show the loginViewController 
}

现在退出方法

if currentUser.hasPressedLogoutButton() {
   // show the loginViewController 
 }