import PushNotification from 'react-native-push-notification';

// Kanal yaratish (Android uchun)
export const createDefaultChannel = () => {
  PushNotification.createChannel(
    {
      channelId: 'default-channel-id',
      channelName: 'Default Channel',
      channelDescription: 'Default channel for notifications',
      soundName: 'default',
      importance: 4,
      vibrate: true,
    },
    created => console.log(`createChannel returned '${created}'`),
  );
};

// Notification konfiguratsiyasi
export const configureNotifications = () => {
  PushNotification.configure({
    onNotification: function (notification) {
      notification.finish((PushNotification as any).FetchResult.NoData);
    },
    requestPermissions: true,
  });

  createDefaultChannel();
};

// Test notification
export const showTestNotification = () => {
  PushNotification.localNotification({
    channelId: 'default-channel-id',
    autoCancel: true,
    largeIcon: 'ic_launcher',
    smallIcon: 'ic_notification',
    vibrate: true,
    vibration: 300,
    playSound: true,
    soundName: 'default',
    title: 'Test Xabar',
    message: 'Bu test xabar',
    importance: 'high',
    priority: 'high',
  });
};
