// Import the Firebase Admin SDK
const admin = require("firebase-admin");

// Initialize Firebase Admin SDK with the path to your service account key file
const serviceAccount = require("/Applications/Projects/FirebaseMessage/appice-77b2f-firebase-adminsdk-yx5ee-5eb73c961e.json");
admin.initializeApp({
    credential: admin.credential.cert(serviceAccount)
});

// FCM token of the device you want to send the notification to
const deviceFCMToken = "fdY5r83lTtSsAnIkoMxwcT:APA91bEP0CINNPI4-RueMTTzjixlfhW3xlTzLIdMIQJ5lcwWioTdM-fwacQ82GS2YknfdTgr_QfBBl8Kgud08P2pApUVPt7qhis4PkIHBfe1-OfJFidJuKsw5VJOWkoeYwSxI5H_prCK";

// Create the message object
const message = {
    token: deviceFCMToken,
    android: {
        priority: 'high', 
        data: {
            message: JSON.stringify({
                camp_id: '560e33f914f50d0e8b2f5c21',
                tid: '65fa81615e5b821ff1b15b47',
                nh: 'appICE Push Notification V2 bhaiya Coming',
                nd: 'Description hai to chota to hoga hi, appICE Push Notification V2 bhaiya Coming',
                ni: 'https://appice-prod-campaign-images.objectstore.e2enetworks.net//1710915661456_v97rFFRPPMHiqM1XNP0FFP6D.png',
                end: '',
                eni: 'https://appice-prod-campaign-images.objectstore.e2enetworks.net//1711447043745_avslRh5AjKDG-9UEmt_tyNzG.jpg',
                eurl: '',
                et: 'dl',
                actions: [

                ],
                sound: false,
                vibrate: false,
                badge: false,
                cdata: {
                    "category": "offer"
                },
                nid: '74c00dfa-8f44-4f7b-a859-cc704f14fc0a',
                mid: '74c00dfa-8f44-4f7b-a859-cc704f14fc0a',
                ai_tag: 'ai_pn',
                ed: '1712241000000',
                dtype: 'a'
            })
        }
    }
};

console.log(message)
// Send the message
admin.messaging().send(message)
    .then((response) => {
        console.log('Successfully sent message:', response); // Log success message
    })
    .catch((error) => {
        console.error('Error sending message:', error.errorInfo); // Log error message
    });