I want to generate messages from clients on my site, and send messages to a target device. It's simple with an ajax(jquery) request like this:
$.ajax({
url: 'https://fcm.googleapis.com/fcm/send',
type: 'POST',
contentType: "application/json",
dataType: 'json',
data: JSON.stringify({
"notification": {
"title": title,
"body": msg,
"sound": "default"
},
"to": "XXXXXXXXXXXX"
}),
beforeSend: function(xhr) {
xhr.setRequestHeader('Authorization', 'key=YYYYYYYYYY');
}
});
But, then don't I need to keep the XXXXXXXXXXXX device key, and YYYYYYYYYY API key private? If not, I'm worried people start scraping these up and spamming from totally unrelated services?