使用Parse iOS处理多个设备上的登录 [英] Handling Login on Multiple Devices using Parse iOS

查看:79
本文介绍了使用Parse iOS处理多个设备上的登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在当前游戏项目中的登录场景有问题:

I have a problem with this login scenario in current game project:

  • 用户使用其帐户详细信息登录(先前在Parse后端上注册的PFUser)
  • 他们玩了一段时间,然后离开游戏(仍然登录)
  • 他们登录另一台设备并播放

我想以某种方式注销其他设备,因为在同一时间不应有两个或两个以上的已登录设备,因为它是多人游戏.

I would like to somehow log the other device out since there shouldn't be TWO or more logged in devices AT THE SAME time because it's a multiplayer game.

如何检测用户是否在其他地方登录?处理在许多地方登录的同一用户的最佳方法是什么?我想防止覆盖数据和不一致.预先感谢.

How can I detect whether the user is logged in somewhere else? What is the best approach to handle same user logged in in many places? I want to prevent overwriting data and inconsistency. Thanks in advance.

推荐答案

您可以为每次游戏安装生成唯一的标识符(只是存储在用户默认设置中的UUID).每次用户登录时,请将标识符更新为存储在服务器上的用户信息.当您将任何编辑内容上传到服务器时,您可以发送标识符并使​​用云代码对其进行检查(或首先检查该标识符),以决定登录名是否仍然有效.如果您发现登录名无效,则如何检查取决于您要执行的操作.更为有效的途径是使用云代码并发回该应用程序处理的错误响应,以警告用户并采取注销措施.

You can generate a unique identifier for each installation of your game (just a UUID stored in user defaults). Each time a use logs in, update the identifier into your user information stored on the server. When you upload any edit to the server you can send the identifier and check it with cloud code (or check the identifier first) to decide if the login is still valid. How you check depends on what you want to do if you find the login to be invalid. The more efficient route is to use cloud code and send back an error response that the app handles to alert the user and action the logout.

这篇关于使用Parse iOS处理多个设备上的登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆