我尝试使用REST API来取消我使用API(使用include_player_ids
和单个收件人)发送给单个用户的待处理通知,但是如果不通过REST我就无法执行此操作API KEY,这不应该发生,因为manual它在我发送的条件中说不是必需的。
我做错了什么或者可能是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"
]
}
答案 0 :(得分:0)
答案比我想象的要容易。要排除通知,我无法使用$.get()
,我必须明确说明我要删除。
所以,这很好用:
$.ajax({
url: "https://onesignal.com/api/v1/notifications/"+notificationId+"?app_id="+appId,
type: "DELETE"
});