initialize static method
Initialize the CloudX SDK
appKey - Your CloudX app key
testMode - Set to true to enable test mode (shows test ads)
Returns true if initialization was successful
Returns false if initialization fails or platform is not supported
Platform Support:
- Android: ✅ Production-ready
- iOS: ❌ Not supported (returns false)
Implementation
static Future<bool> initialize({
required String appKey,
bool testMode = false,
}) async {
final arguments = <String, dynamic>{
'appKey': appKey,
'testMode': testMode,
};
try {
final result = await _invokeMethod<bool>('initSDK', arguments);
// Log warning on iOS since it's not supported
if (Platform.isIOS && (result == null || !result)) {
debugPrint('⚠️ CloudX iOS SDK is not yet supported.');
debugPrint('⚠️ Currently only Android is fully supported.');
}
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;
}
}