Troubleshooting - Flutter SDK
Use Realm with the macOS App Sandbox
If you are developing with the Realm Flutter SDK in the macOS App Sandbox, network requests do not work by default due to built-in macOS security settings. Network access is required to use Atlas App Services and Device Sync.
To enable network requests, add the following code to both the files
macos/Runner/DebugProfile.entitlements
and macos/Runner/Release.entitlements
:
<!-- Other entitlements --> <key>com.apple.security.network.client</key> <true/> <!-- Other entitlements -->
You can still use Realm locally without adding this network access permission.
For more information about Flutter development for macOS, refer to Building macOS apps with Flutter in the Flutter documentation.
Connect to App Services Using Android 7 or Older
To use App Services with the Realm SDK on a device using Android 7 or older,
you must add an HTTP client with a custom Let's Encrypt Transport Layer Security (TLS) encryption certificate
to the App
.
This is due to a known issue using Flutter on devices running Android 7 or older to connect to web servers that use Let's Encrypt TLS certificates. As App Services server uses a Let's Encrypt TLS certificate, you must add the custom certificate.
You can download the Let's Encrypt certificate to add to your app by clicking this link: https://letsencrypt.org/certs/lets-encrypt-r3.pem
To set up the custom HTTP client, adapt the following code example to your app.
import 'package:realm_dart/realm.dart'; import "dart:io"; import "dart:convert"; HttpClient createCustomHttpsClient(String cert) { SecurityContext context = SecurityContext.defaultContext; try { final bytes = utf8.encode(cert); context.setTrustedCertificatesBytes(bytes); } on TlsException catch (e) { final message = e.osError?.message ?? ""; if (!message.contains('CERT_ALREADY_IN_HASH_TABLE')) { rethrow; } } return HttpClient(context: context); } App createAppWithCustomHttpsClient( String letsEncryptCertificate, String appId) { HttpClient httpClient = createCustomHttpsClient(letsEncryptCertificate); final appConfig = AppConfiguration(appId, httpClient: httpClient); return App(appConfig); } final letsEncryptCertificate = "<LET'S ENCRYPT CERTIFICATE>"; final appId = "<YOUR APP ID>"; final app = createAppWithCustomHttpsClient(letsEncryptCertificate, appId);