On this page
Pass the App ID for your App, which you can find in the App Services UI.
let app = App(id: YOUR_APP_SERVICES_APP_ID) // replace YOUR_APP_SERVICES_APP_ID with your App ID
You can pass a configuration object to
let configuration = AppConfiguration( baseURL: "https://realm.mongodb.com", // Custom base URL transport: nil, // Custom RLMNetworkTransportProtocol localAppName: "My App", localAppVersion: "3.14.159", defaultRequestTimeoutMS: 30000 ) let app = App(id: "my-app-services-app-id", configuration: configuration)
You can create multiple App client instances to connect to multiple Apps. All App client instances that share the same App ID use the same underlying connection.
You Can't Change an App Config After Initializing the App
When you initialize the App client, the configuration is cached internally. Attempting to "close" an App and then re-open it with a changed configuration within the same process has no effect. The client continues to use the cached configuration.
New in version 10.41.0.
You can set the
enableSessionMultiplexing bool on the
AppConfiguration to specify
whether the Realm Swift SDK should open a connection to the server for each
synced realm, or share a connection to the server for all synced realms.
If you do not specify a value for this bool, Realm defaults to sharing a single connection per App Services user for all synced realms.
let configuration = AppConfiguration(enableSessionMultiplexing: false) let app = App(id: YOUR_APP_SERVICES_APP_ID, configuration: configuration)
New in version 10.41.0.
You can set various sync timeout options on the
syncTimeouts property can accept a
SyncTimeoutOptions object to
override default values for these settings.
For a complete list of the available timeout settings and their definitions, refer to RLMSyncTimeoutOptions.
let syncTimeoutOptions = SyncTimeoutOptions( connectTimeout: 30000, connectionLingerTime: 5000, pingKeepalivePeriod: 10000, pongKeepaliveTimeout: 10000, fastReconnectLimit: 30000 ) let configuration = AppConfiguration(syncTimeouts: syncTimeoutOptions) let app = App(id: YOUR_APP_SERVICES_APP_ID, configuration: configuration)
The Realm Swift SDK supports connecting to an Atlas App Services App for a range of Apple operating systems depending on the Xcode version and Realm Swift SDK version. Connecting to an App Services App enables:
Authentication and User Management
Calling an Atlas Function
Querying a MongoDB Atlas Data Source
For current information about supported operating systems, refer to OS Support.
At this time, the Realm Swift SDK does not support connecting to an App Services App from watchOS.