Skip to content

Commit

Permalink
Merge pull request #81 from zzeebbii/master
Browse files Browse the repository at this point in the history
Added a method to cancel the scheduled OneSignal notifications
  • Loading branch information
berkayk authored Sep 23, 2018
2 parents 6d4214f + 1cd0a93 commit 125e963
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/OneSignalClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ public function sendNotificationToSegment($message, $segment, $url = null, $data
$this->sendNotificationCustom($params);
}

public function deleteNotification($notificationId, $appId = null) {
$this->requiresAuth();

if(!$appId)
$appId = $this->appId;
$notificationCancelNode = "/$notificationId?app_id=$this->appId";
return $this->delete(self::ENDPOINT_NOTIFICATIONS . $notificationCancelNode);

}

/**
* Send a notification with custom parameters defined in
* https://documentation.onesignal.com/reference#section-example-code-create-notification
Expand Down Expand Up @@ -400,4 +410,12 @@ public function put($endPoint) {
public function get($endPoint) {
return $this->client->get(self::API_URL . $endPoint, $this->headers);
}

public function delete($endPoint) {
if($this->requestAsync === true) {
$promise = $this->client->deleteAsync(self::API_URL . $endPoint, $this->headers);
return (is_callable($this->requestCallback) ? $promise->then($this->requestCallback) : $promise);
}
return $this->client->delete(self::API_URL . $endPoint, $this->headers);
}
}

0 comments on commit 125e963

Please sign in to comment.