Yes! DataStore can be used with or without any cloud synchronization.
Android
Cloud sync is enabled when you add an API plugin. To disable cloud sync, don't add AWSApiPlugin()
:
Amplify.addPlugin(AWSDataStorePlugin())
// Comment out this line:
// Amplify.addPlugin(AWSApiPlugin())
Amplify.configure(applicationContext)
iOS
Sync is enabled when there is an API plugin present. To disable sync, do not add AWSAPIPlugin()
:
let dataStorePlugin =
AWSDataStorePlugin(modelRegistration: AmplifyModels())
try Amplify.add(plugin: dataStorePlugin)
// Comment out this line:
// try Amplify.add(plugin: AWSAPIPlugin())
try Amplify.configure()
JavaScript
The approach is slightly different. Look for any API configurations in the aws-exports.js
file, and remove them. Specifically, you should remove any config entries with aws_appsync_*
in the prefix:
const awsmobile = {
// ...
"aws_appsync_graphqlEndpoint": "https://yourid.appsync-api.us-east-1.amazonaws.com/graphql",
"aws_appsync_region": "us-east-1",
"aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS",
// ...
};
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…