import rp from "request-promise"

export const sendNotification = async (notification,token) => {
  try {
  
const options = {
    method: 'POST',
    uri: 'https://fcm.googleapis.com/fcm/send',
    headers: {
      Authorization: 'key=AAAAp7-ivbI:APA91bHiZ43UlES3GRuMTu4te-RGqss5ymkVG3DI4wy9nD69ID1lh9NE4RifQe0uBTQcVP5qQPN4s1QANosMK9lyYfl5Sd9ItUR6C0wT4ep8gMNnN3fLvVPV0P6gFAXHlGAwgLQj1wyM',
      'Content-Type': 'application/json',
    },
    body: {
      notification,
      to: token,
    },
    json: true,
  };

const response = await rp(options);
    return response.data;
  } catch (error) {
    console.error('Error sending notification:', error);
    throw new Error(error);
  }
};

