├── .editorconfig ├── .styleci.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── composer.json └── src ├── Exceptions └── CouldNotCreateMessage.php ├── PusherChannel.php ├── PusherMessage.php └── PusherPushNotificationsServiceProvider.php /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at http://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_size = 4 9 | indent_style = space 10 | end_of_line = lf 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | preset: laravel 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `pusher-push-notifications` will be documented in this file 4 | 5 | ## 1.0.0 - 2016-XX-XX 6 | 7 | - initial release 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | Please read and understand the contribution guide before creating an issue or pull request. 6 | 7 | ## Etiquette 8 | 9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code 10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be 11 | extremely unfair for them to suffer abuse or anger for their hard work. 12 | 13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the 14 | world that developers are civilized and selfless people. 15 | 16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient 17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. 18 | 19 | ## Viability 20 | 21 | When requesting or submitting new features, first consider whether it might be useful to others. Open 22 | source projects are used by many developers, who may have entirely different needs to your own. Think about 23 | whether or not your feature is likely to be used by other users of the project. 24 | 25 | ## Procedure 26 | 27 | Before filing an issue: 28 | 29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. 30 | - Check to make sure your feature suggestion isn't already present within the project. 31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress. 32 | - Check the pull requests tab to ensure that the feature isn't already in progress. 33 | 34 | Before submitting a pull request: 35 | 36 | - Check the codebase to ensure that your feature doesn't already exist. 37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. 38 | 39 | ## Requirements 40 | 41 | If the project maintainer has any additional requirements, you will find them listed here. 42 | 43 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). 44 | 45 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 46 | 47 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 48 | 49 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 50 | 51 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 52 | 53 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 54 | 55 | **Happy coding**! 56 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) Mohamed Said 4 | 5 | > Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | > 12 | > The above copyright notice and this permission notice shall be included in 13 | > all copies or substantial portions of the Software. 14 | > 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pusher Beams push notifications channel for Laravel 8.x & 9.x 2 | 3 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-notification-channels/pusher-push-notifications.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/pusher-push-notifications) 4 | [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) 5 | [![Build Status](https://img.shields.io/travis/laravel-notification-channels/pusher-push-notifications/master.svg?style=flat-square)](https://travis-ci.org/laravel-notification-channels/pusher-push-notifications) 6 | [![StyleCI](https://styleci.io/repos/65379321/shield)](https://styleci.io/repos/65379321) 7 | [![SensioLabsInsight](https://img.shields.io/sensiolabs/i/9015691f-130d-4fca-8710-72a010abc684.svg?style=flat-square)](https://insight.sensiolabs.com/projects/9015691f-130d-4fca-8710-72a010abc684) 8 | [![Quality Score](https://img.shields.io/scrutinizer/g/laravel-notification-channels/pusher-push-notifications.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/pusher-push-notifications) 9 | [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/laravel-notification-channels/pusher-push-notifications/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/pusher-push-notifications/?branch=master) 10 | [![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/pusher-push-notifications.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/pusher-push-notifications) 11 | 12 | This package makes it easy to send [Pusher Beams push notifications](https://pusher.com/docs/beams) with Laravel. 13 | 14 | Please note that this notification channel should not be confused with Pusher Channels. 15 | 16 | Also please note that prior to version 2.0, this package integrated with Pusher's beta push notifications service that was part of Pusher Channels. Please see Pusher's [migration guide](https://www.pusher.com/docs/channels/push_notifications/migration-guide) for more information. 17 | 18 | ## Contents 19 | 20 | - [Pusher Beams push notifications channel for Laravel 8.x & 9.x](#pusher-beams-push-notifications-channel-for-laravel-55-6x-7x--8x) 21 | - [Contents](#contents) 22 | - [Installation](#installation) 23 | - [Setting up your Pusher account](#setting-up-your-pusher-account) 24 | - [Usage](#usage) 25 | - [Available Message methods](#available-message-methods) 26 | - [Sending to multiple platforms](#sending-to-multiple-platforms) 27 | - [Routing a message](#routing-a-message) 28 | - [Publish to users](#publish-to-users) 29 | - [Changelog](#changelog) 30 | - [Testing](#testing) 31 | - [Security](#security) 32 | - [Contributing](#contributing) 33 | - [Credits](#credits) 34 | - [License](#license) 35 | 36 | 37 | ## Installation 38 | 39 | You can install the package via composer: 40 | 41 | ```bash 42 | composer require laravel-notification-channels/pusher-push-notifications 43 | ``` 44 | 45 | ### Setting up your Pusher account 46 | 47 | Before using this package you should set up a Pusher Beams account. Here are the steps required. 48 | 49 | - Login to https://dash.pusher.com/ 50 | - Select the "Beams" product. 51 | - Select your instance from the list or create a new instance. 52 | - Click on the "Settings" tab. 53 | - Upload your APNS Certificate and/or add your FCM Server key. 54 | - Now select the "Keys" tab. 55 | - Copy your `Instance Id`, and `Secret Key`. 56 | - Add a new entry to in your `config/services.php` file: 57 | ```php 58 | 'pusher' => [ 59 | 'beams_instance_id' => 'Your Instance Id', 60 | 'beams_secret_key' => 'Your Secret Key', 61 | ], 62 | ``` 63 | - You're now good to go. 64 | 65 | ## Usage 66 | 67 | Now you can use the channel in your `via()` method inside the Notification class. 68 | 69 | ```php 70 | use NotificationChannels\PusherPushNotifications\PusherChannel; 71 | use NotificationChannels\PusherPushNotifications\PusherMessage; 72 | use Illuminate\Notifications\Notification; 73 | 74 | class AccountApproved extends Notification 75 | { 76 | public function via($notifiable) 77 | { 78 | return [PusherChannel::class]; 79 | } 80 | 81 | public function toPushNotification($notifiable) 82 | { 83 | return PusherMessage::create() 84 | ->iOS() 85 | ->badge(1) 86 | ->sound('success') 87 | ->body("Your {$notifiable->service} account was approved!"); 88 | } 89 | } 90 | ``` 91 | 92 | ### Available Message methods 93 | 94 | - `platform('')`: Accepts a string value of `iOS`, `Android` or `web`. 95 | - `iOS()`: Sets the platform value to iOS. 96 | - `android()`: Sets the platform value to Android. 97 | - `web()`: Sets the platform value to web. 98 | - `link()`: Accepts a string value which will lead to URI specified on notification click. 99 | - `title('')`: Accepts a string value for the title. 100 | - `body('')`: Accepts a string value for the body. 101 | - `sound('')`: Accepts a string value for the notification sound file. Notice that if you leave blank the default sound value will be `default`. 102 | - `icon('')`: Accepts a string value for the icon file. (Android Only) 103 | - `badge(1)`: Accepts an integer value for the badge. (iOS Only) 104 | - `setOption($key, $value)`: Allows you to set any value in the message payload. See the [request body section of the Pusher Beam docs](https://pusher.com/docs/beams/reference/publish-api#request-body) for more information. 105 | 106 | ### Sending to multiple platforms 107 | 108 | You can send a single message to an iOS device and an Android device at the same time using the `withiOS()` and `withAndroid()` method: 109 | 110 | ```php 111 | public function toPushNotification($notifiable) 112 | { 113 | $message = "Your {$notifiable->service} account was approved!"; 114 | 115 | return PusherMessage::create() 116 | ->iOS() 117 | ->badge(1) 118 | ->body($message) 119 | ->withAndroid( 120 | PusherMessage::create() 121 | ->title($message) 122 | ->icon('icon') 123 | ); 124 | } 125 | ``` 126 | 127 | > - Notice that iOS is the default platform, which means you don't have to call `->iOS()`. 128 | > - When using `withAndroid()`, `withiOS()` or `withWeb()` you don't have to define the platform, it's done behind the scenes for you. 129 | 130 | ### Routing a message 131 | 132 | By default, the pusher "interest" messages will be sent to will be defined using the {notifiable}.{id} convention, for example `App.User.1`, 133 | however you can change this behaviour by including a `routeNotificationFor()` in the notifiable class. 134 | 135 | I.e. if you are pushing notification on `User` model, you can go to `App\Models\User` class and implement method: 136 | 137 | ```php 138 | public function routeNotificationForPusherPushNotifications($notification): string 139 | { 140 | return 'your.custom.interest.string'; 141 | } 142 | ``` 143 | 144 | `PusherPushNotifications()` in the notifiable class method returns the interest name. 145 | 146 | ### Publish to users 147 | 148 | You can publish to users in the same way that you publish to interests but you must add the following variable to the notifiable model: 149 | 150 | ``` 151 | class Client extends Model 152 | { 153 | use Notifiable; 154 | 155 | public $pushNotificationType = 'users'; 156 | } 157 | ``` 158 | 159 | ## Changelog 160 | 161 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. 162 | 163 | ## Testing 164 | 165 | ```bash 166 | $ composer test 167 | ``` 168 | 169 | ## Security 170 | 171 | If you discover any security related issues, please email themsaid@gmail.com instead of using the issue tracker. 172 | 173 | ## Contributing 174 | 175 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 176 | 177 | ## Credits 178 | 179 | - [Mohamed Said](https://github.com/themsaid) 180 | - [Marcel Pociot](https://github.com/mpociot) 181 | - [Freek Van der Herten](https://github.com/freekmurze) 182 | - [Sebastian De Deyne](https://github.com/sebastiandedeyne) 183 | - [All Contributors](../../contributors) 184 | 185 | ## License 186 | 187 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 188 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel-notification-channels/pusher-push-notifications", 3 | "description": "Pusher native Push Notifications driver.", 4 | "keywords": [ 5 | "pusher-push-notifications", 6 | "laravel", 7 | "pusher", 8 | "notifications" 9 | ], 10 | "homepage": "https://github.com/LaravelNotificationChannels/pusher-push-notifications", 11 | "license": "MIT", 12 | "authors": [ 13 | { 14 | "name": "Mohamed Said", 15 | "email": "themsaid@gmail.com", 16 | "homepage": "https://themsaid.com" 17 | }, 18 | { 19 | "name": "Marcel Pociot", 20 | "email": "hello@marcelpociot.com", 21 | "homepage": "http://marcelpociot.com" 22 | }, 23 | { 24 | "name": "Freek Van der Herten", 25 | "email": "freek@spatie.be", 26 | "homepage": "https://spatie.be" 27 | }, 28 | { 29 | "name": "Sebastian De Deyne", 30 | "email": "sebastian@spatie.be", 31 | "homepage": "https://sebastiandedeyne.com" 32 | } 33 | ], 34 | "require": { 35 | "php": ">=8.0", 36 | "illuminate/events": "~8.0 || ~9.0 || ^10.0 || ^11.0", 37 | "illuminate/notifications": "~8.0 || ~9.0 || ^10.0 || ^11.0", 38 | "illuminate/queue": "~8.0 || ~9.0 || ^10.0 || ^11.0", 39 | "illuminate/support": "~8.0 || ~9.0 || ^10.0 || ^11.0", 40 | "pusher/pusher-push-notifications": "^2.0" 41 | }, 42 | "require-dev": { 43 | "mockery/mockery": "^1.3", 44 | "phpunit/phpunit": "^9.5 || ^10.5" 45 | }, 46 | "autoload": { 47 | "psr-4": { 48 | "NotificationChannels\\PusherPushNotifications\\": "src" 49 | } 50 | }, 51 | "autoload-dev": { 52 | "psr-4": { 53 | "NotificationChannels\\PusherPushNotifications\\Test\\": "tests" 54 | } 55 | }, 56 | "scripts": { 57 | "test": "vendor/bin/phpunit" 58 | }, 59 | "config": { 60 | "sort-packages": true 61 | }, 62 | "extra": { 63 | "laravel": { 64 | "providers": [ 65 | "NotificationChannels\\PusherPushNotifications\\PusherPushNotificationsServiceProvider" 66 | ] 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/Exceptions/CouldNotCreateMessage.php: -------------------------------------------------------------------------------- 1 | pushNotificationType ?? self::INTERESTS; 33 | 34 | $data = $notifiable->routeNotificationFor('PusherPushNotifications') 35 | ?: self::defaultName($notifiable); 36 | 37 | try { 38 | $notificationType = sprintf('publishTo%s', Str::ucfirst($type)); 39 | 40 | $this->beamsClient->{$notificationType}( 41 | Arr::wrap($data), 42 | $notification->toPushNotification($notifiable)->toArray() 43 | ); 44 | } catch (Throwable $exception) { 45 | $this->events->dispatch( 46 | new NotificationFailed($notifiable, $notification, 'pusher-push-notifications', ['exception' => $exception]) 47 | ); 48 | } 49 | } 50 | 51 | /** 52 | * Get the default name for the notifiable. 53 | * 54 | * @param mixed $notifiable 55 | * @return string 56 | */ 57 | public static function defaultName(mixed $notifiable): string 58 | { 59 | $class = str_replace('\\', '.', get_class($notifiable)); 60 | 61 | return $class.'.'.$notifiable->getKey(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/PusherMessage.php: -------------------------------------------------------------------------------- 1 | platform = $platform; 83 | 84 | return $this; 85 | } 86 | 87 | /** 88 | * Set the platform to iOS. 89 | * 90 | * @return $this 91 | */ 92 | public function iOS(): self 93 | { 94 | $this->platform = 'iOS'; 95 | 96 | return $this; 97 | } 98 | 99 | /** 100 | * Set the platform to Android. 101 | * 102 | * @return $this 103 | */ 104 | public function android(): self 105 | { 106 | $this->platform = 'Android'; 107 | 108 | return $this; 109 | } 110 | 111 | /** 112 | * Set the platform to web. 113 | * 114 | * @return $this 115 | */ 116 | public function web(): self 117 | { 118 | $this->platform = 'web'; 119 | 120 | return $this; 121 | } 122 | 123 | /** 124 | * Set an extra message to be sent to Android. 125 | * 126 | * @param \NotificationChannels\PusherPushNotifications\PusherMessage $message 127 | * @return $this 128 | * 129 | * @throws CouldNotCreateMessage 130 | */ 131 | public function withAndroid(self $message): self 132 | { 133 | $this->withExtra($message->android()); 134 | 135 | return $this; 136 | } 137 | 138 | /** 139 | * Set an extra message to be sent to iOS. 140 | * 141 | * @param \NotificationChannels\PusherPushNotifications\PusherMessage $message 142 | * @return $this 143 | * 144 | * @throws CouldNotCreateMessage 145 | */ 146 | public function withiOS(self $message): self 147 | { 148 | $this->withExtra($message->iOS()); 149 | 150 | return $this; 151 | } 152 | 153 | /** 154 | * Set an extra message to be sent to web. 155 | * 156 | * @param \NotificationChannels\PusherPushNotifications\PusherMessage $message 157 | * @return $this 158 | * 159 | * @throws CouldNotCreateMessage 160 | */ 161 | public function withWeb(self $message): self 162 | { 163 | $this->withExtra($message->web()); 164 | 165 | return $this; 166 | } 167 | 168 | /** 169 | * Set an extra message to be sent to another platform. 170 | * 171 | * @param \NotificationChannels\PusherPushNotifications\PusherMessage $message 172 | * @return void 173 | * 174 | * @throws CouldNotCreateMessage 175 | */ 176 | private function withExtra(self $message): void 177 | { 178 | if ($message->getPlatform() === $this->platform) { 179 | throw CouldNotCreateMessage::platformConflict($this->platform); 180 | } 181 | 182 | $this->extraMessage = $message; 183 | } 184 | 185 | /** 186 | * Set the message title. 187 | * 188 | * @param string $value 189 | * @return $this 190 | */ 191 | public function title(string $value): self 192 | { 193 | $this->title = $value; 194 | 195 | return $this; 196 | } 197 | 198 | /** 199 | * Set the message body. 200 | * 201 | * @param string $value 202 | * @return $this 203 | */ 204 | public function body(string $value): self 205 | { 206 | $this->body = $value; 207 | 208 | return $this; 209 | } 210 | 211 | /** 212 | * Set the message sound (Android). 213 | * 214 | * @param string $value 215 | * @return $this 216 | */ 217 | public function sound(string $value): self 218 | { 219 | $this->sound = $value; 220 | 221 | return $this; 222 | } 223 | 224 | /** 225 | * Set the message icon (Android). 226 | * 227 | * @param string $value 228 | * @return $this 229 | */ 230 | public function icon(string $value): self 231 | { 232 | $this->icon = $value; 233 | 234 | return $this; 235 | } 236 | 237 | /** 238 | * Set the message badge (iOS). 239 | * 240 | * @param int $value 241 | * @return $this 242 | */ 243 | public function badge(int $value): self 244 | { 245 | $this->badge = $value; 246 | 247 | return $this; 248 | } 249 | 250 | /** 251 | * Set the message link. 252 | * 253 | * @param string $value 254 | * @return $this 255 | */ 256 | public function link(string $value): self 257 | { 258 | $this->link = $value; 259 | 260 | return $this; 261 | } 262 | 263 | /** 264 | * @param string $key 265 | * @param mixed $value 266 | * @return $this 267 | */ 268 | public function setOption(string $key, mixed $value): self 269 | { 270 | $this->options[$key] = $value; 271 | 272 | return $this; 273 | } 274 | 275 | /** 276 | * Get an array representation of the message. 277 | * 278 | * @return array 279 | */ 280 | public function toArray(): array 281 | { 282 | return match ($this->platform) { 283 | 'Android' => $this->toAndroid(), 284 | 'web' => $this->toWeb(), 285 | default => $this->toiOS(), 286 | }; 287 | } 288 | 289 | /** 290 | * Format the message for iOS. 291 | * 292 | * @return array 293 | */ 294 | public function toiOS(): array 295 | { 296 | $message = [ 297 | 'apns' => [ 298 | 'aps' => [ 299 | 'alert' => [ 300 | 'title' => $this->title, 301 | 'body' => $this->body, 302 | ], 303 | 'sound' => $this->sound, 304 | 'badge' => $this->badge, 305 | ], 306 | ], 307 | ]; 308 | 309 | $this->formatMessage($message); 310 | 311 | return $message; 312 | } 313 | 314 | /** 315 | * Format the message for Android. 316 | * 317 | * @return array 318 | */ 319 | public function toAndroid(): array 320 | { 321 | $message = [ 322 | 'fcm' => [ 323 | 'notification' => array_filter([ 324 | 'title' => $this->title, 325 | 'body' => $this->body, 326 | 'sound' => $this->sound, 327 | 'icon' => $this->icon, 328 | ]), 329 | ], 330 | ]; 331 | 332 | $this->formatMessage($message); 333 | 334 | return $message; 335 | } 336 | 337 | /** 338 | * Format the message for web. 339 | * 340 | * @return array 341 | */ 342 | public function toWeb(): array 343 | { 344 | $message = [ 345 | 'web' => [ 346 | 'notification' => array_filter([ 347 | 'title' => $this->title, 348 | 'body' => $this->body, 349 | 'sound' => $this->sound, 350 | 'icon' => $this->icon, 351 | 'deep_link' => $this->link, 352 | ]), 353 | ], 354 | ]; 355 | 356 | $this->formatMessage($message); 357 | 358 | return $message; 359 | } 360 | 361 | /** 362 | * Return the current platform. 363 | * 364 | * @return string 365 | */ 366 | public function getPlatform(): string 367 | { 368 | return $this->platform; 369 | } 370 | 371 | /** 372 | * Format the final Payload. 373 | * 374 | * @param $message 375 | */ 376 | private function formatMessage(&$message): void 377 | { 378 | if ($this->extraMessage) { 379 | $message = array_merge($message, $this->extraMessage->toArray()); 380 | } 381 | 382 | foreach ($this->options as $option => $value) { 383 | Arr::set($message, $option, $value); 384 | } 385 | } 386 | } 387 | -------------------------------------------------------------------------------- /src/PusherPushNotificationsServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->when(PusherChannel::class) 16 | ->needs(PushNotifications::class) 17 | ->give(function () { 18 | $config = config('services.pusher'); 19 | 20 | return new PushNotifications([ 21 | 'instanceId' => $config['beams_instance_id'], 22 | 'secretKey' => $config['beams_secret_key'], 23 | ]); 24 | }); 25 | } 26 | } 27 | --------------------------------------------------------------------------------