1

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

4

1 回答 1

0

Yes, this is possible to do. The appsync client allows you to specify your database location as part of the config. Here is some sample code that shows you how it is done

// 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)

        ....

You can use this mechanism to include the pre-populated database in your app and then configure appsync with that path for the database.

于 2018-08-22T20:51:11.693 回答