我试图使用REST取消一个挂起的通知,该通知是我发送给一个也使用该API的用户的(与include_player_ids和单个收件人一起发送的),但是如果不传递REST键,这是不可能的,因为在手册中,它说在条件下我发送这个消息是不必要的。
我是不是做错了什么,或者是OneSignal的服务出了问题?以下是代码:
//Creates the notification
$.post(
"https://onesignal.com/api/v1/notifications",
{
"app_id": appId,
"include_player_ids": [userId],
"send_after": later,
"template_id": templateId
},
function(data){
localStorage.ni = data.id;
}
);
//Cancel the notification
var notificationId = localStorage.ni;
$.get("https://onesignal.com/api/v1/notifications/"+notificationId+"?app_id="+appId);以下是取消请求的响应:
{
"errors":
[
"Please include a case-sensitive header of Authorization: Basic <YOUR-REST-API-KEY-HERE> with a valid REST API key."
],
"reference":
[
"https://documentation.onesignal.com/docs/accounts-and-keys#section-keys-ids"
]
}发布于 2017-10-07 22:37:02
答案比我想象的要容易。要排除一个通知,我不能使用$.get(),我必须明确地说我想要删除它们。
所以,这件事很好:
$.ajax({
url: "https://onesignal.com/api/v1/notifications/"+notificationId+"?app_id="+appId,
type: "DELETE"
});https://stackoverflow.com/questions/46392603
复制相似问题