// Fazer uma chamada post Json
// url:https://onesignal.com/api/v1/notifications
// Header "Content-Type":"application/json"
// "Authorization":"ODM5MzJjYjEtMDdhMi00NDQwLTg4YjItNzUxOTJjNGRhZGY3"
// Propriedade send_after para agendar o push pra data passada
// https://documentation.onesignal.com/reference#create-notification
// https://documentation.onesignal.com/docs/web-push-sdk#section-create-notification
// https://documentation.onesignal.com/docs/cordova-sdk#section--postnotification-
{
"app_id": "220978c0-6406-46b8-88bf-5553ae66e3f8",
"include_player_ids": ["1d084e6d-0ea6-48e7-a948-b5e3243a3773"],
"data": {"foo": "bar"},
"contents": {"en": "English Message"},
"send_after": "Wed Nov 20 2019 20:22:00 GMT-0300 (Brasilia Standard Time)"
}
// Usando api do anota facil
axios.post('https://onesignal.com/api/v1/notifications', {
headers: {
'Content-Type': 'application/json',
'Authorization': 'ODM5MzJjYjEtMDdhMi00NDQwLTg4YjItNzUxOTJjNGRhZGY3'
},
{
"app_id": "220978c0-6406-46b8-88bf-5553ae66e3f8",
"include_player_ids": ["1d084e6d-0ea6-48e7-a948-b5e3243a3773"],
"data": {"foo": "bar"},
"contents": {"en": "English Message"},
"send_after": "Wed Nov 20 2019 20:22:00 GMT-0300 (Brasilia Standard Time)"
}
})
.then((response) => {
console.log(response)
})
.catch((error) => {
console.log(error)
})
//Correcao do post do axios
const updateWebNotification = (
appID,
authID,
senderID,
dateTime,
data = { foo: 'bar' },
contents = { en: 'English Message' }
) => {
axios
.post(
'https://onesignal.com/api/v1/notifications',
{
app_id: appID,
include_player_ids: senderID,
data: data,
contents: contents,
send_after: dateTime,
},
{
headers: {
'Content-Type': 'application/json',
Authorization: authID,
},
}
)
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error);
});
};