我只想根据用户子 ID 下载选择性数据,但 Amplify 允许我运行一次配置命令,选择性同步用于此目的,我正在使用放大登录方法并从中获取子 ID,我只想根据该子 ID获取数据,但我必须重新配置 Amplify,以便将基于该子 ID,但对于 Amplify Auth 服务,Amplify 已配置,我无法添加基于子 ID 的配置
这是我在应用程序类中使用的代码
/* Add the Amplify Plugins */
Amplify.addPlugin(AWSApiPlugin())
Amplify.addPlugin(AWSCognitoAuthPlugin())
Amplify.addPlugin(AWSDataStorePlugin.builder().dataStoreConfiguration(
DataStoreConfiguration.builder()
.syncExpression(Rooms::class.java) { Devices.SUB.ge(AwsConstants.AMPLIFY_SUB_ID) }
.syncExpression(Scenes::class.java) { Devices.SUB.ge(AwsConstants.AMPLIFY_SUB_ID) }
.syncExpression(Devices::class.java) { Devices.SUB.ge(AwsConstants.AMPLIFY_SUB_ID) }
.syncExpression(Automations::class.java) { Devices.SUB.ge(AwsConstants.AMPLIFY_SUB_ID) }
.syncExpression(MasterNodes::class.java) { Devices.SUB.ge(AwsConstants.AMPLIFY_SUB_ID) }
.build()
).build())
Amplify.configure(applicationContext)
我只想在准备好数据之前添加配置以下载选择性数据
/* Starting the DataStore Syncing */
Amplify.DataStore.start(
{ Log.i(Constants.TAG_AMPLIFY, "DataStore started") },
{}
)