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



我已经做了登录页面和注册页面,工作得很好,但它不会重定向用户到登录页面。首先用户需要登录被重定向到个人资料页面,如果用户的电子邮件或密码是错误的应用程序将不允许用户继续,我也需要帮助与注销用户。

在这里查看我的导航流程请帮忙

我用Swift以后的版本编码

让我们从您的后端服务器,有某种方法来检查是否有人当前登录。它返回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 
}

现在输入logout方法

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

最新更新