由于其离线功能,我们正在考虑将AWS AppSync用于我们的下一个移动项目。使用AppSync是否可以发布预填充了内容的移动应用程序数据库的移动应用程序(iOS / Android)?这是为了避免在安装应用后首次连接大型内容时下载速度较慢。
答案 0 :(得分:0)
是的,这是可以做到的。 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。