"use strict";

import axios from 'axios';
import { Platform } from 'react-native';
import { store } from '../../roomStore';
const PUSH_API_URL = 'https://push.ethoradev.com/api/v1';
const pushAxios = axios.create({
  baseURL: PUSH_API_URL,
  headers: {
    'Content-Type': 'application/json'
  }
});
export async function subscribeToPushNotifications(fcmToken, userJid, projectName = '') {
  const deviceType = Platform.select({
    ios: 'ios',
    android: 'android',
    default: 'web'
  });
  const payload = {
    projectId: projectName,
    registrationToken: fcmToken,
    deviceType,
    jid: `${userJid}@xmpp.ethoradev.com`
  };
  console.log('payload', payload);
  try {
    const token = store.getState().chatSettingStore?.user?.token || '';
    const response = await pushAxios.post('/subscriptions', payload, {
      headers: {
        Authorization: `Bearer ${token}`
      }
    });
    console.log('Successfully subscribed to push notifications', response.data);
    return response.data;
  } catch (error) {
    console.error('Failed to subscribe to push notifications:', error);
  }
}
//# sourceMappingURL=push.api.js.map