Skip to content

Commit

Permalink
Clarify sync demo README. (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
elle-j committed Nov 17, 2022
1 parent 97a7682 commit abcfbf3
Showing 1 changed file with 48 additions and 16 deletions.
64 changes: 48 additions & 16 deletions MultiplatformDemoWithSync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,57 @@ running between an Android, iOS, macOS and JVM app.

# Steps to build:

## 1 - Create a Realm Sync App on MongoDB Atlas

- Follow the tutorial at https://www.mongodb.com/docs/atlas/tutorial/create-atlas-account/ or watch
the screencast https://www.youtube.com/watch?v=lqo0Yf7lnyg.

- The App must be configured for Flexible Sync with Dev Mode enabled.

- A user must be created under "App Users > Add New User". A fake email and password like "[email protected]" and "123456" can be used.

- Insert the app identifier and the created user/password in
[shared/src/commonMain/kotlin/io/realm/kotlin/demo/util/Constants.kt](./shared/src/commonMain/kotlin/io/realm/kotlin/demo/util/Constants.kt)
## 1 - Create an Atlas Account and Deploy a Free Cluster

- Follow the steps in the [Get Started with Atlas tutorial](https://www.mongodb.com/docs/atlas/getting-started/) up until (and including) **Create a database user for your cluster**.
- Or watch the [YouTube screencast](https://www.youtube.com/watch?v=lqo0Yf7lnyg).

## 2 - Create an Atlas App Services App

- Follow the [Create an App with the App Services UI guide](https://www.mongodb.com/docs/atlas/app-services/manage-apps/create/create-with-ui/#std-label-create-a-realm-app).
- When creating the App, choose the **Real-time Sync** template.
- Once created, in the **App Services** console click on your newly created App.
- Keep **Dev Mode** enabled.
- Navigate to **Device Sync** through the left navigation menu.
- Under **Sync Type**, select **Flexible Sync** (or follow the [Enable Flexible Sync guide](https://www.mongodb.com/docs/atlas/app-services/sync/configure/enable-sync/#enable-flexible-sync)).
- Under **Define Permissions**, add:
```json
{
"rules": {},
"defaultRoles": [
{
"name": "owner-read-write",
"applyWhen": {},
"read": {
"_id": "%%user.id"
},
"write": {
"_id": "%%user.id"
}
}
]
}
```
- Navigate to **App Users** through the left navigation menu.
- Click on **Add New User** and enter a fake email and password between 6 and 128 characters.
- Copy the App ID at the top of the left navigation menu.
- Insert the copied ID and the created user/password in
[shared/src/commonMain/kotlin/io/realm/kotlin/demo/util/Constants.kt](./shared/src/commonMain/kotlin/io/realm/kotlin/demo/util/Constants.kt):
```kotlin
object Constants {
val MONGODB_REALM_APP_ID = "[REPLACE ME]"
val MONGODB_REALM_APP_USER = "[REPLACE ME]"
val MONGODB_REALM_APP_PASSWORD = "[REPLACE ME]"
}
```

## 2 - Build and run for Android
## 3 - Build and run for Android

```
./gradlew :androidApp:installDebug
./gradlew :androidApp:installDebug
```

## 3 - Build and run for iOS
## 4 - Build and run for iOS

```
./gradlew shared:podInstall
Expand All @@ -34,7 +66,7 @@ pod install
open iosApp.xcworkspace
```

## 4 - Build and run for macOS
## 5 - Build and run for macOS

```
./gradlew shared:podInstall
Expand All @@ -43,7 +75,7 @@ pod install
open macosApp.xcworkspace
```

## 5 - Build and run for JVM
## 6 - Build and run for JVM

```
./gradlew :jvmApp:run
Expand Down

0 comments on commit abcfbf3

Please sign in to comment.