Code Monkey home page Code Monkey logo

amplify-android-samples's Introduction

amplify-android-samples

This repository contains sample applications to demonstrate usage of Amplify Android.

  • todo: Demonstrates DataStore with a Todo schema

Setup Using Amplify Admin UI

Note: You may need to create an AWS account and configure it before testing the backend.

  • Clone the sample GitHub repo under your preferred directory.
  • Change directory to root folder of whichever language you want to use. For Java: cd getting-started/todo/java. For Kotlin: cd getting-started/todo/kotlin.
  • Follow the Instructions to provision Amplify and run this application. (Skip "Set up fullstack project" and "Integrate in your app" and any instructions that changes code)

Setup using Amplify CLI

  1. Please follow the instructions to sign up for an AWS Account and setup the Amplify CLI.

  2. Initialize Amplify in your project by running the following command from your project directory:

amplify init

Provide the responses shown after each of the following prompts.

? Enter a name for the environment
    `dev`
? Choose your default editor:
    `Android Studio`
? Where is your Res directory:
    `app/src/main/res`
? Select the authentication method you want to use: 
    `AWS profile`
? Please choose the profile you want to use 
    `default`

Wait until provisioning is finished. Upon successfully running amplify init, you will see a configuration file created in ./app/src/main/res/raw/ called amplifyconfiguration.json. This file will be bundled into your application so that the Amplify libraries know how to reach your provisioned backend resources at runtime.

  1. Configure DataStore category

From your project directory, run the following command to add the Amplify API category and create a new GraphQL API:

amplify add api

Provide the responses shown after each of the following prompts.

? Please select from one of the below mentioned services: 
    `GraphQL`
? Provide API name: 
    `ToDoAPI`
? Choose the default authorization type for the API 
    `Amazon Cognito User Pool`
? Do you want to configure advanced settings for the GraphQL API 
    `Yes, I want to make some additional changes.`
? Configure additional auth types? 
    `No`
? Enable conflict detection? 
    `Yes`
? Select the default resolution strategy 
    `Auto Merge`
? Do you have an annotated GraphQL schema? 
    `Yes`
? Provide your schema file path: 
    `schema.graphql`

This will configure the Amplify API category to provision a GraphQL service with CRUD operations to persist data locally and automatically synchronize local data to the cloud with Amplify DataStore.

The GraphQL schema is defined as follows:

enum Priority {
    LOW
    NORMAL
    HIGH
}

type Todo @model @auth(rules: [{allow: public}]) {
    id: ID!
    name: String!
    priority: Priority!
    completedAt: AWSDateTime
}
  1. Generate model files

    From your project directory, run amplify codegen models. This will generate model files from the GraphQL schema. You'll find the generated files under amplify-android-samples/getting-started/todo/java/app/src/main/java/com/amplifyframework/datastore/generated/model/(if you are using Java version) or amplify-android-samples/getting-started/todo/kotlin/app/src/main/java/com/amplifyframework/datastore/generated/model/(if you are using Kotlin version) directory.

  2. Once finished, run amplify push to publish your changes. Provide the responses shown after each of the following prompts.

? Are you sure you want to continue?
    `Yes`
? Do you want to generate code for your newly created GraphQL API?
    `No`

Upon completion, amplifyconfiguration.json should be updated to reference these provisioned backend resources.

Run the app

  • Build and run the project on an emulator or Android device in Android Studio.

amplify-android-samples's People

Contributors

abdallahshaban557 avatar changxu0306 avatar dengdan154 avatar gpanshu avatar palpatim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amplify-android-samples's Issues

Sample with existing AWS resources

Hi,

This sample walkthrough uses Amplify from AWS SDK. Can a sample with Amplify framework be updated which uses existing AWS resources. The documentation gives the details but expecting more of a sample.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.