带有登录和离线模式的 Swift 应用程序 [英] Swift-Application with Login and offlinemodus

查看:31
本文介绍了带有登录和离线模式的 Swift 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这对你们中的许多人来说是一个非常简单的问题,但我需要一些提示.

maybe this is for many of you a very simple question but I need some tipps.

我将创建一个可以在线和离线使用的应用程序.在网络服务器上使用了 FOSUserBundle 的 symfony.登录并在网络浏览器中工作非常好.

I will create a app, which can be used online and offline. At the webserver is symfony with the FOSUserBundle used. Login and working in the webbrowser works very well.

我的目标是:

在 iOS 设备上启动应用程序.当用户未登录时,将查看应用程序的登录表单.登录应该能记住.

Start the app on a iOS-Device. When the user are not be logged in, then the loginform from the application would be viewed. The login should be able to remember.

登录后,应用程序会将来自网络服务器的数据与设备数据库同步.

The app will after the login synchronize the data from the webserver with the device-database.

当用户没有移动连接并且他没有注销自己时,应用程序应该显示带有他的数据的屏幕.我的意思是这就像来自 facebook 的信使一样.

When the user didn't have a mobileconnection and he didn't log himself out, then the application should show the screen with his data. I mean this like the messenger from facebook.

移动设备上的所有视图都是用 swift 完全开发的.没有来自网络服务器的网络视图.

All views on the mobiledevice are completely developed with swift. There is not a webview from the webserver.

请你给我一点提示,我要搜索的东西?

Please can you give me for this a little tip, for what I have to search?

我搜索了 FOSOAuthServerBundle,但我认为我的方法不对.

I search for FOSOAuthServerBundle but I dont think that I am on the right way.

推荐答案

我用 symfony 作为后端为我的应用做了什么:

What I did for my app with symfony as a backend:

  • 在 symfony 中有一个控制器,它从应用程序接收登录数据并检查用户名和密码是否正确.在此确认后,控制器将使用我在应用程序中需要的数据(json 格式)进行回答

  • having a controller in symfony which receives the login data from the app and check if the username and password are correct. After this confirmation, the controller is answering with the data I need in the app (json format)

在应用程序中,我保存了用户名和密码(我需要这个,因为如果没有连接到互联网,我需要根据某些内容检查登录信息).

in the app I save the username and password (I need this because if there is no connection to the internet I need to check the login against something).

这意味着,每次用户通过互联网连接成功登录时,都会保存用户名和密码.

It means, that every time the user logged in successful with internet connection, the username and password are saved.

  • 在应用程序中,我将带有密钥存档的 json-response 保存到文档文件夹中.

  • in the app I save the json-response with key-archiving into documents folder.

在用户成功登录后,应用程序始终从文档文件夹加载 json 文件.

the app always loads the json-file from documents folder, after the user logged in successfully.

互联网连接:

1) 根据 Symfony 中的 FOSUserbundle 检查用户名和密码

1) check username and password against the FOSUserbundle in Symfony

2) 在应用中保存用户名和密码

2) save the username and password in the app

3) 将响应作为文件保存到文档文件夹中

3) save the response as file into documents folder

4) 让应用从该文件夹加载其内容

4) let the app load its content from that folder

没有互联网连接

1) 根据上次使用互联网连接成功登录时存储在应用程序中的凭据检查用户名和密码

1) check username and password against the credentials stored in the app from the last successful login with internet connection

2) 让应用从文档文件夹加载其内容

2) let the app load its content from the documents folder

这篇关于带有登录和离线模式的 Swift 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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