AWS Amplify provides a high-level interface to perform different categories of cloud operations. Each category is fulfilled by a plugin. You specify which plugins to use during setup.
The default plugins that we provide are designed to facilitate interaction with Amazon Web Services (AWS). But, the Amplify framework is designed to be extensible to any other backend or service.
If you're new to the project, checkout the Getting Started Guide.
Model your app's data. Save, query, and observe changes to your data from a local repository. Let DataStore synchronize your local data with the Cloud. Our default implemenation syncs local data to/from an Amazon DynamoDB database, via an Amazon AppSync front-end.
Easy auth and request signing against multiple REST endpoints. Our default plugin works great with Amazon API Gateway.
Data modeling and simple auth against GraphQL endpoints. Our default plugin targets AppSync.
Collect and report usage data for your app. Our default plugin communicates with Amazon Pinpoint.
Store and retrieve files in the Cloud. We use Amazon Simple Storage Service (S3) by default.
The Amplify Framework supports Android API level 16 (Android 4.1) and above.
To begin, include Amplify from your app
module's build.gradle
dependencies section:
dependencies {
// Only specify modules that provide functionality your app will use
implementation 'com.amplifyframework:aws-datastore:0.10.0'
implementation 'com.amplifyframework:aws-api:0.10.0'
implementation 'com.amplifyframework:aws-storage-s3:0.10.0'
implementation 'com.amplifyframework:aws-analytics-pinpoint:0.10.0'
}
Amplify Android uses Java 8 features. Please add a compileOptions
block inside your app's build.gradle
, as below:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
The default plugins for Amplify Android rely on the AWS Mobile Client to provide authentication with AWS services.
Please see Getting Started with Authentication for full details.
In summary, you need to ensure AWSMobileClient
is initialized
before interfacting with Amplify
:
AWSMobileClient awsAuth = AWSMobileClient.getInstance();
Context context = getApplicationContext();
awsAuth.initialize(context, new Callback<UserStateDetails>() {
@Override
public void onResult(UserStateDetails userStateDetails) {
Amplify.addPlugin(new AWSApiPlugin()); // For example
Amplify.configuration(context);
Toast.makeText(context, "OK!", Toast.LENGTH_SHORT);
}
@Override
public void onError(Exception error) {
Toast.makeText(context, "Uh oh...", Toast.LENGTH_SHORT);
}
});
Please note that AWSMobileClient
initialization is not required
when using the AWSApiPlugin
or AWSDataStorePlugin
with api key as the
authorization mode.
This library is licensed under the Apache 2.0 License.
We appreciate your feedback -- comments, questions, and bug reports. Please submit a GitHub issue, and we'll get back to you.
Please see the Contributor's Guide.