From 0b2ff8c7b3fc3e18bb8c0e06a8e4e750a5788163 Mon Sep 17 00:00:00 2001 From: sucipto Date: Wed, 30 Aug 2017 16:44:16 +0700 Subject: [PATCH] Add Multi App with api_key parameter send api_key to sendNotificationCustom with multi api_key in one app --- src/OneSignalClient.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/OneSignalClient.php b/src/OneSignalClient.php index d194982..8df63c0 100644 --- a/src/OneSignalClient.php +++ b/src/OneSignalClient.php @@ -218,9 +218,14 @@ public function sendNotificationToSegment($message, $segment, $url = null, $data public function sendNotificationCustom($parameters = []){ $this->requiresAuth(); $this->usesJSON(); - + // By Sucipto + if ($parameters['api_key']) { + $this->headers['headers']['Authorization'] = 'Basic '.$parameters['api_key']; + } // Make sure to use app_id - $parameters['app_id'] = $this->appId; + if (!$parameters['app_id']) { + $parameters['app_id'] = $this->appId; + } // Make sure to use included_segments if (empty($parameters['included_segments']) && empty($parameters['include_player_ids'])) { @@ -294,4 +299,4 @@ public function put($endPoint) { } return $this->client->put(self::API_URL . $endPoint, $this->headers); } -} \ No newline at end of file +}