initialize static method

Future<void> initialize()

Initializes version detection by fetching and caching the OS version.

This should be called early in the app lifecycle, but can be called multiple times safely - it will only fetch once.

Implementation

static Future<void> initialize() async {
  if (_isInitialized) return;

  try {
    if (Platform.isIOS) {
      _cachedIOSVersion = await CupertinoNativePlatform.instance.getMajorOSVersion();
    } else if (Platform.isMacOS) {
      _cachedMacOSVersion = await CupertinoNativePlatform.instance.getMajorOSVersion();
    }
  } catch (e) {
    debugPrint('Failed to get OS version: $e');
    // On error, assume older version for safety
    if (Platform.isIOS) {
      _cachedIOSVersion = 15; // Safe fallback
    } else if (Platform.isMacOS) {
      _cachedMacOSVersion = 12; // Safe fallback
    }
  }

  _isInitialized = true;
}