Add an App id
App id
In the App, we'll add a reference to the Atlas Services App we've created before. In App Services, find and copy the App ID.
GoodHabitsRealmApp.swift
let app: RealmSwift.App? = RealmSwift.App(id: "My App Id")
SyncContentView
To wait for the connection, do login, etc. we'll use a view that will take care of the different connection states our app will have. This new View is called SyncContentView, son we'll show that on App Startup.
GoodHabitsRealmApp.swift
import SwiftUI
import RealmSwift
@main
struct GoodHabitsRealmAppApp: SwiftUI.App {
let app: RealmSwift.App? = RealmSwift.App(id: "My App Id")
var body: some Scene {
WindowGroup {
SyncContentView(app: app!)
}
}
}