Skip to content

Commit 125e963

Browse files
authored
Merge pull request #81 from zzeebbii/master
Added a method to cancel the scheduled OneSignal notifications
2 parents 6d4214f + 1cd0a93 commit 125e963

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/OneSignalClient.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,16 @@ public function sendNotificationToSegment($message, $segment, $url = null, $data
295295
$this->sendNotificationCustom($params);
296296
}
297297

298+
public function deleteNotification($notificationId, $appId = null) {
299+
$this->requiresAuth();
300+
301+
if(!$appId)
302+
$appId = $this->appId;
303+
$notificationCancelNode = "/$notificationId?app_id=$this->appId";
304+
return $this->delete(self::ENDPOINT_NOTIFICATIONS . $notificationCancelNode);
305+
306+
}
307+
298308
/**
299309
* Send a notification with custom parameters defined in
300310
* https://documentation.onesignal.com/reference#section-example-code-create-notification
@@ -400,4 +410,12 @@ public function put($endPoint) {
400410
public function get($endPoint) {
401411
return $this->client->get(self::API_URL . $endPoint, $this->headers);
402412
}
413+
414+
public function delete($endPoint) {
415+
if($this->requestAsync === true) {
416+
$promise = $this->client->deleteAsync(self::API_URL . $endPoint, $this->headers);
417+
return (is_callable($this->requestCallback) ? $promise->then($this->requestCallback) : $promise);
418+
}
419+
return $this->client->delete(self::API_URL . $endPoint, $this->headers);
420+
}
403421
}

0 commit comments

Comments
 (0)