initialize static method
Initialize the CloudX SDK
appKey - Your CloudX app key
allowIosExperimental - Set to true to enable iOS SDK (alpha/development only)
Returns true if initialization was successful
Returns false if initialization fails or platform is not supported
Platform Support:
- Android: ✅ Production-ready
- iOS: ⚠️ Alpha/Development only - requires
allowIosExperimental: true
Implementation
static Future<bool> initialize({
required String appKey,
bool allowIosExperimental = false,
}) async {
// Platform guard: iOS SDK is not production-ready
if (Platform.isIOS && !allowIosExperimental) {
debugPrint('⚠️ CloudX iOS SDK is not yet production-ready.');
debugPrint('⚠️ Currently only Android is fully supported.');
debugPrint(
'⚠️ For iOS alpha testing, use: CloudX.initialize(appKey: "...", allowIosExperimental: true)',);
debugPrint('⚠️ For production iOS access, contact the CloudX team.');
debugPrint('⚠️ SDK initialization skipped on iOS.');
return false;
}
final arguments = <String, dynamic>{
'appKey': appKey,
};
try {
final result = await _invokeMethod<bool>('initSDK', arguments);
await _ensureEventStreamInitialized();
return result ?? false;
} on PlatformException catch (e) {
debugPrint('❌ CloudX initialization failed: ${e.message}');
debugPrint(' Error code: ${e.code}');
if (e.details != null) {
debugPrint(' Details: ${e.details}');
}
return false;
}
}