Giter Club home page Giter Club logo

realm-kotlin-jetpack-compose-sync-example's Introduction

realm-kotlin-jetpack-compose-sync-example

Sample application on how to implement an Android Application with Kotlin, Jetpack Compose and AppServices/Realm Flexible Sync. It also contains a simple backend in a HTML file that can be used to interact with the application.

Functionality

Implement a basic To Do List, where you can add tasks and mark them as Done or Discarded. It's actually pretty simple but showcases a few functionalities from Realm.

Adding a new task

Creating a New Task

Changing a task status

Changing Task Status

Receiving Notifications from the Back Office

Notification from Backoffice

Receiving a new task from the Back Office

Receiving task from the Backoffice

Requirements to run

How To Configure

  1. Create a new Free Account in MongoDB Atlas: https://www.mongodb.com/cloud
  2. Create a new cluster in AWS, Ireland, named "Test". You can keep everything else as default. Create Cluster Page
1 2
Choose Region Change Name
  1. Also, create a new administrator user. Follow the steps in the screen.

  2. Go to Access Manager, Project Access, and API Keys. Create API Key

  3. Remember to add your own public IP to the Access List. Do not use 0.0.0.0. Store the public key and the private key.

  4. Login with your Realm cli:

realm-cli login --api-key "$PUBLIC_API_KEY" --private-api-key "$PRIVATE_API_KEY" --yes
  1. Deploy the application for the first time:
realm-cli push -y
  1. If you are using a paid version of MongoDB Atlas instead of the free tier. You can enable hosting. For our example, we won't use hosting.
  2. Create the users for the Android application:
realm-cli users create --type email --email '[email protected]' --password '123456'
realm-cli users create --type email --email '[email protected]' --password '123456'
  1. Get the user ID from the admin user (it will be an hexadecimal string, like 63d018499d6f043532957a89) and save it.

  2. Connect to MongoDB. Here is an example on how to use Compass and Atlas.

1 2 3
  1. Open the MongoShell >_MONGOSH tab on the bottom of the Compass window, and run the following command:
use androidapp
db.CustomUserData.insertOne({ 
  isGlobalAdmin: true,
  ownerId: "$YOUR_ADMIN_ID_IN_STEP_9"
})
  1. Open the file realm_config.json and copy the app_id.
  2. Replace in all the project files the string <your-app-id> with the app_id value.
  3. Start the application using an Android phone or emulator (using Android Studio).

How to test synchronisation

When you create a new item in the application, it should be created also in Atlas. If you still have Compass open, you can navigate to the androidapp.TodoListItem collection:

How to check sync

How to test notifications

Open the backend, it's a simple html file. You can use the open command to open the browser:

open hosting/files/index.html

Login with the example user:

And send a notification using the Notify button.

How to check notifications

Note

This application is not supported by MongoDB, it's just a sample application that I've done to showcase a few functionalities from Realm and Atlas AppServices.

realm-kotlin-jetpack-compose-sync-example's People

Contributors

kmruiz avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.