【问题标题】:Is it possible to prepolulate an AWS AppSync iOS client?是否可以预填充 AWS AppSync iOS 客户端?
【发布时间】:2019-01-27 11:40:17
【问题描述】:

我们正在考虑将 AWS AppSync 用于我们的下一个移动项目,因为它具有离线功能。使用 AppSync 是否可以发布带有预填充内容的移动应用程序数据库的移动应用程序(iOS / Android)?这是为了避免在安装应用程序后首次连接时下载缓慢的大型内容。

【问题讨论】:

    标签: ios aws-appsync aws-sdk-ios aws-ios aws-appsync-ios


    【解决方案1】:

    是的,这是可以做到的。 appsync 客户端允许您将数据库位置指定为配置的一部分。这是一些示例代码,向您展示了它是如何完成的

    // Set up Amazon Cognito credentials
    let credentialsProvider = AWSCognitoCredentialsProvider(regionType: CognitoIdentityRegion, identityPoolId: CognitoIdentityPoolId)
    
    // Specify the location to your custom local DB
    let databaseURL = URL(fileURLWithPath:NSTemporaryDirectory()).appendingPathComponent("custom_db_name")
    
        do {
            // Initialize the AWS AppSync configuration
            let appSyncConfig = try AWSAppSyncClientConfiguration(url: AppSyncEndpointURL, serviceRegion: AppSyncRegion, credentialsProvider: credentialsProvider, databaseURL:databaseURL)
    
            // Initialize the AWS AppSync client
            appSyncClient = try AWSAppSyncClient(appSyncConfig: appSyncConfig)
    
            ....
    

    您可以使用此机制将预填充的数据库包含在您的应用中,然后使用该数据库的路径配置 appsync。

    【讨论】:

    • 感谢您的回复。这真是个好消息。我期待着尝试一下!
    猜你喜欢
    • 1970-01-01
    • 2018-08-06
    • 2019-02-21
    • 2020-08-30
    • 2021-09-23
    • 2014-03-13
    • 2021-11-20
    • 1970-01-01
    • 2020-12-05
    相关资源
    最近更新 更多