Skip to content

Commit 2a32bea

Browse files
authored
Update related Pusher package (#73)
1 parent a3bfe64 commit 2a32bea

11 files changed

+116
-172
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ build
33
composer.phar
44
composer.lock
55
.phpunit.result.cache
6+
/.idea
7+
/.vscode

.travis.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

README.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Pusher Beams push notifications channel for Laravel 5.5+, 6.x, 7.x & 8.x
1+
# Pusher Beams push notifications channel for Laravel 8.x & 9.x
22

33
[![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)
44
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
@@ -17,7 +17,7 @@ Also please note that prior to version 2.0, this package integrated with Pusher'
1717

1818
## Contents
1919

20-
- [Pusher Beams push notifications channel for Laravel 5.5+, 6.x, 7.x & 8.x](#pusher-beams-push-notifications-channel-for-laravel-55-6x-7x--8x)
20+
- [Pusher Beams push notifications channel for Laravel 8.x & 9.x](#pusher-beams-push-notifications-channel-for-laravel-55-6x-7x--8x)
2121
- [Contents](#contents)
2222
- [Installation](#installation)
2323
- [Setting up your Pusher account](#setting-up-your-pusher-account)
@@ -38,7 +38,7 @@ Also please note that prior to version 2.0, this package integrated with Pusher'
3838

3939
You can install the package via composer:
4040

41-
``` bash
41+
```bash
4242
composer require laravel-notification-channels/pusher-push-notifications
4343
```
4444

@@ -51,7 +51,7 @@ Before using this package you should set up a Pusher Beams account. Here are the
5151
- Select your instance from the list or create a new instance.
5252
- Click on the "Settings" tab.
5353
- Upload your APNS Certificate and/or add your FCM Server key.
54-
- Now select the "Credentials" tab.
54+
- Now select the "Keys" tab.
5555
- Copy your `Instance Id`, and `Secret Key`.
5656
- Add a new entry to in your `config/services.php` file:
5757
```php
@@ -66,7 +66,7 @@ Before using this package you should set up a Pusher Beams account. Here are the
6666

6767
Now you can use the channel in your `via()` method inside the Notification class.
6868

69-
``` php
69+
```php
7070
use NotificationChannels\PusherPushNotifications\PusherChannel;
7171
use NotificationChannels\PusherPushNotifications\PusherMessage;
7272
use Illuminate\Notifications\Notification;
@@ -132,18 +132,12 @@ public function toPushNotification($notifiable)
132132
By default, the pusher "interest" messages will be sent to will be defined using the {notifiable}.{id} convention, for example `App.User.1`,
133133
however you can change this behaviour by including a `routeNotificationFor()` in the notifiable class.
134134

135-
I.e. if you are pushing notification on ``User`` model, you can go to `App\User` class and implement method:
135+
I.e. if you are pushing notification on `User` model, you can go to `App\Models\User` class and implement method:
136136

137-
```
138-
public function routeNotificationFor($channel)
137+
```php
138+
public function routeNotificationForPusherPushNotifications($notification): string
139139
{
140-
if($channel === 'PusherPushNotifications'){
141-
return 'your.custom.interest.string';
142-
}
143-
144-
$class = str_replace('\\', '.', get_class($this));
145-
146-
return $class.'.'.$this->getKey();
140+
return 'your.custom.interest.string';
147141
}
148142
```
149143

@@ -168,7 +162,7 @@ Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recen
168162

169163
## Testing
170164

171-
``` bash
165+
```bash
172166
$ composer test
173167
```
174168

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
}
3333
],
3434
"require": {
35-
"php": ">=7.4",
36-
"illuminate/events": "~7.0 || ~8.0 || ~9.0",
37-
"illuminate/notifications": "~7.0 || ~8.0 || ~9.0",
38-
"illuminate/queue": "~7.0 || ~8.0 || ~9.0",
39-
"illuminate/support": "~7.0 || ~8.0 || ~9.0",
40-
"pusher/pusher-push-notifications": "^1.1"
35+
"php": ">=8.0",
36+
"illuminate/events": "~8.0 || ~9.0",
37+
"illuminate/notifications": "~8.0 || ~9.0",
38+
"illuminate/queue": "~8.0 || ~9.0",
39+
"illuminate/support": "~8.0 || ~9.0",
40+
"pusher/pusher-push-notifications": "^2.0"
4141
},
4242
"require-dev": {
4343
"mockery/mockery": "^1.3",

src/Exceptions/CouldNotCreateMessage.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
class CouldNotCreateMessage extends Exception
88
{
99
/**
10-
* @param string $platform
10+
* @param string $platform
1111
* @return static
1212
*/
13-
public static function invalidPlatformGiven($platform)
13+
public static function invalidPlatformGiven(string $platform): static
1414
{
1515
return new static("Platform `{$platform}` is invalid. It should be either `iOS` or `Android`.");
1616
}
1717

1818
/**
19-
* @param $platform
19+
* @param string $platform
2020
* @return static
2121
*/
22-
public static function platformConflict($platform)
22+
public static function platformConflict(string $platform): static
2323
{
2424
return new static("You are trying to send an extra message to `{$platform}` while the original message is to `{$platform}`.");
2525
}

src/PusherChannel.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,8 @@ class PusherChannel
1616
{
1717
public const INTERESTS = 'interests';
1818

19-
protected PushNotifications $beamsClient;
20-
21-
private Dispatcher $events;
22-
23-
public function __construct(PushNotifications $beamsClient, Dispatcher $events)
19+
public function __construct(protected PushNotifications $beamsClient, private Dispatcher $events)
2420
{
25-
$this->beamsClient = $beamsClient;
26-
$this->events = $events;
2721
}
2822

2923
/**
@@ -49,7 +43,7 @@ public function send($notifiable, Notification $notification): void
4943
);
5044
} catch (Throwable $exception) {
5145
$this->events->dispatch(
52-
new NotificationFailed($notifiable, $notification, 'pusher-push-notifications')
46+
new NotificationFailed($notifiable, $notification, 'pusher-push-notifications', ['exception' => $exception])
5347
);
5448
}
5549
}
@@ -60,7 +54,7 @@ public function send($notifiable, Notification $notification): void
6054
* @param mixed $notifiable
6155
* @return string
6256
*/
63-
public static function defaultName($notifiable): string
57+
public static function defaultName(mixed $notifiable): string
6458
{
6559
$class = str_replace('\\', '.', get_class($notifiable));
6660

0 commit comments

Comments
 (0)