在iOS上使用Azure App Service做离线同步和身份认证

有个项目需要对数据进行云端备份,调研了几家云备份数据服务平台后决定采用微软Azure的服务,主要原因是提供了APP Service这样可以进行脱机数据同步的服务。

https://docs.azure.cn/zh-cn/app-service-mobile/app-service-mobile-ios-get-started-offline-data


1. 创建Azure SQL数据库

2. 创建APP Service,选择MobileService,命名为“Test”

3. 在“Test”中选择Quick Start,选择刚才创建SQL数据库表,然后Azure会为我们自动创建一个TodoItem的数据库表

4.下载示例程序iOS Swift版

5.在示例程序中有一个coredata的数据库文件,包含id, createdAt, updatedAt, deleted四个默认的属性,还有一个complete的自定义属性

6. 看一下APPDelegate文件,相比默认的文件,添加了

// MARK: - Core Data stack
    
    lazy var applicationDocumentsDirectory: URL = {
        // The directory the application uses to store the Core Data store file.
        let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
        return urls[urls.count-1] 
    }()
    
    lazy var managedObjectModel: NSManagedObjectModel = {
        // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
        let modelURL = Bundle.main.url(forResource: "QSTodoDataModel", withExtension: "momd")!
        ret
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值