RChat – A Chat app built with SwiftUI and Realm
RChat is a chat application. Members of a chat room share messages, photos, location, and presence information with each other. The initial version is an iOS (Swift & SwiftUI) app, but we will use the same data model and backend Realm application to build an Android version in the future.
Read about the Realm data architecture here and how the app was built here.
Building and running the app
- If you don’t already have one, create a MongoDB Atlas Cluster, keeping the default name of
Cluster0
. - Install the Realm CLI and create an API key pair.
- Download the repo and install the Realm app:
git clone https://github.com/ClusterDB/RChat.git
cd RChat/RChat-Realm/RChat
realm-cli login --api-key <your new public key> --private-api-key <your new private key>
realm-cli import # Then answer prompts, naming the app RChat
- From the Atlas UI, click on the Realm logo and you will see the RChat app. Open it and copy the App Id
- (Optional) Use
mongoimport
to import the empty database from thedump
folder to create database indexes - Open the iOS project (using Xcode 13.2 or later)
cd ../../RChat-iOS
open RChat.xcodeproj
- Update
RChatApp.swift
with your Realm App Id and then build
The
new-schema
branch contains all of the iOS and backend Realm app code needed to add a new feature to tag chat message as high priority. This includes schema and code changes. You can find all of the steps to safely make such a schema change in a production app in Migrating Your iOS App’s Synced Realm Schema in Production.
The
V2-schema
branch contains all of the iOS and backend Realm app code needed to make theChatMessage.author
field non-optional. You can find all of the steps to safely make such a schema change in a production app in Migrating Your iOS App’s Synced Realm Schema in Production.