import { Platform } from 'react-native';
import UNSnapshotProtectionHelper from '../nativeModulesHelpers/UNSanpshotProtectionHelper/UNSnapshotProtectionHelper';
import { UnitComponentsSDK } from '../unitComponentsSdkManager/UnitComponentsSdkManager';
import { UNComponentsSnapshotProtectionStrategy } from '../types/shared/securitySettings';
import { useEffect } from 'react';

export const useSnapshotProtection = () => {
  /**
   * This hook provides snapshot protection specifically for Android.
   * For iOS, a native service is utilized instead.
   */
  useEffect(() => {
    if (!UnitComponentsSDK.isInitialized()) {
      return;
    }

    if (UnitComponentsSDK.getSecuritySettings().snapshotProtectionStrategy == UNComponentsSnapshotProtectionStrategy.None) {
      return;
    }

    if (Platform.OS == 'android') {
      UNSnapshotProtectionHelper.setAndroidSecurity();
    }
  }, []);
};
