import {
  requireNativeComponent,
  UIManager,
  Platform,
  ViewStyle,
  NativeModules,
} from 'react-native';

const LINKING_ERROR =
  `The package 'react-native-aps' doesn't seem to be linked. Make sure: \n\n` +
  Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
  '- You rebuilt the app after installing the package\n' +
  '- You are not using Expo managed workflow\n';

type ApsProps = {
  color: string;
  style: ViewStyle;
};

// const { APSModule } = NativeModules;

// const isIOS = Platform.OS === 'ios';

const ComponentName = 'ApsView';

export const ApsView =
  UIManager.getViewManagerConfig(ComponentName) != null
    ? requireNativeComponent<ApsProps>(ComponentName)
    : () => {
        throw new Error(LINKING_ERROR);
      };

export const getDeviceId = async () => {
  console.log(NativeModules, 'Native Modules ====');
  // return await APSModule.getDeviceID(callback);
  // try {
  //   isIOS ? await APSModule.getDeviceID(null, settingDeviceId)
  //     : await APSModule.getDeviceID(settingDeviceId);
  // } catch (e) {
  //   console.log(e, 'something went wrong native');
  // }
};
