• Stars
    star
    271
  • Rank 151,262 (Top 3 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 8 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pusher Beams notifications channel for Laravel

Pusher Beams push notifications channel for Laravel 8.x & 9.x

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score Code Coverage Total Downloads

This package makes it easy to send Pusher Beams push notifications with Laravel.

Please note that this notification channel should not be confused with Pusher Channels.

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 for more information.

Contents

Installation

You can install the package via composer:

composer require laravel-notification-channels/pusher-push-notifications

Setting up your Pusher account

Before using this package you should set up a Pusher Beams account. Here are the steps required.

  • Login to https://dash.pusher.com/
  • Select the "Beams" product.
  • Select your instance from the list or create a new instance.
  • Click on the "Settings" tab.
  • Upload your APNS Certificate and/or add your FCM Server key.
  • Now select the "Keys" tab.
  • Copy your Instance Id, and Secret Key.
  • Add a new entry to in your config/services.php file:
    'pusher' => [
        'beams_instance_id' => 'Your Instance Id',
        'beams_secret_key' => 'Your Secret Key',
    ],
  • You're now good to go.

Usage

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

use NotificationChannels\PusherPushNotifications\PusherChannel;
use NotificationChannels\PusherPushNotifications\PusherMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [PusherChannel::class];
    }

    public function toPushNotification($notifiable)
    {
        return PusherMessage::create()
            ->iOS()
            ->badge(1)
            ->sound('success')
            ->body("Your {$notifiable->service} account was approved!");
    }
}

Available Message methods

  • platform(''): Accepts a string value of iOS, Android or web.
  • iOS(): Sets the platform value to iOS.
  • android(): Sets the platform value to Android.
  • web(): Sets the platform value to web.
  • link(): Accepts a string value which will lead to URI specified on notification click.
  • title(''): Accepts a string value for the title.
  • body(''): Accepts a string value for the body.
  • sound(''): Accepts a string value for the notification sound file. Notice that if you leave blank the default sound value will be default.
  • icon(''): Accepts a string value for the icon file. (Android Only)
  • badge(1): Accepts an integer value for the badge. (iOS Only)
  • setOption($key, $value): Allows you to set any value in the message payload. See the request body section of the Pusher Beam docs for more information.

Sending to multiple platforms

You can send a single message to an iOS device and an Android device at the same time using the withiOS() and withAndroid() method:

public function toPushNotification($notifiable)
{
    $message = "Your {$notifiable->service} account was approved!";

    return PusherMessage::create()
        ->iOS()
        ->badge(1)
        ->body($message)
        ->withAndroid(
            PusherMessage::create()
                ->title($message)
                ->icon('icon')
        );
}
  • Notice that iOS is the default platform, which means you don't have to call ->iOS().
  • When using withAndroid(), withiOS() or withWeb() you don't have to define the platform, it's done behind the scenes for you.

Routing a message

By default, the pusher "interest" messages will be sent to will be defined using the {notifiable}.{id} convention, for example App.User.1, however you can change this behaviour by including a routeNotificationFor() in the notifiable class.

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

public function routeNotificationForPusherPushNotifications($notification): string
{
    return 'your.custom.interest.string';
}

PusherPushNotifications() in the notifiable class method returns the interest name.

Publish to users

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:

class Client extends Model
{
    use Notifiable;

    public $pushNotificationType = 'users';
}

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

More Repositories

1

telegram

✈️ Telegram Notifications Channel for Laravel
PHP
852
star
2

webpush

Webpush notifications channel for Laravel.
PHP
658
star
3

fcm

Firebase Cloud Messaging (FCM) notifications channel for Laravel
PHP
483
star
4

onesignal

OneSignal notifications channel for Laravel
PHP
275
star
5

discord

Discord notification channel for Laravel
PHP
223
star
6

channels

Submit suggestions & pull requests here for new notification channels
186
star
7

apn

APN push notifications channel for Laravel
PHP
185
star
8

twitter

Twitter Notifications Channel for Laravel
PHP
169
star
9

webhook

Webhook notifications channel for Laravel
PHP
154
star
10

facebook

πŸ“¨ Facebook Notifications Channel for Laravel
PHP
145
star
11

microsoft-teams

Microsoft Teams Notifications Channel for Laravel
PHP
133
star
12

facebook-poster

Use notifications to create posts on Facebook
PHP
130
star
13

authy

@Authy notification channel for @Laravel, with the ability to send in-app, sms, and call verification tokens.
PHP
57
star
14

pushover

πŸ“± Pushover notifications channel for Laravel
PHP
54
star
15

gcm

Laravel Notification Channel for Google GCM (Android)
PHP
54
star
16

aws-sns

AWS SNS notification channel for Laravel
PHP
50
star
17

smsc-ru

smsc.ru notifications channel for Laravel 5.3+
PHP
49
star
18

skeleton

PHP
47
star
19

google-chat

Google Chat notification channel for Laravel
PHP
46
star
20

expo

Expo Notifications Channel for Laravel
PHP
37
star
21

backport

Laravel Notifications for Laravel 5.2 / 5.1
PHP
26
star
22

ionic-push-notifications

Ionic Push Notifications Channel for Laravel
PHP
25
star
23

trello

Trello notifications channel for Laravel
PHP
24
star
24

africastalking

AfricasTalking Notification Channel For Laravel
PHP
23
star
25

messagebird

Messagebird notifications channel for Laravel
PHP
22
star
26

bearychat

BearyChat notifications channel for Laravel
PHP
22
star
27

smsapi

Smsapi notification channel for Laravel 5.5+
PHP
22
star
28

website

Laravel Notifications Channel Website
JavaScript
21
star
29

hipchat

HipChat Notifications Channel for Laravel
PHP
18
star
30

gammu

Gammu SMS notifications channel for Laravel 5.3
PHP
14
star
31

pushbullet

Pushbullet notifications channel for Laravel
PHP
14
star
32

rocket-chat

Rocket.Chat notifications channel for Laravel
PHP
14
star
33

lob

lob.com notifications channel for Laravel
PHP
11
star
34

gitter

Gitter.im notifications channel for Laravel
PHP
10
star
35

pubnub

PubNub Notifications Channel for Laravel
PHP
9
star
36

laravel-notification-channels.github.io

Old Source code of laravel-notification-channels.com
HTML
9
star
37

jet-sms

JetSMS notifications channel for Laravel
PHP
9
star
38

clickatell

Clickatell notifications channel for Laravel
PHP
9
star
39

plivo

Plivo notifications channel for Laravel
PHP
8
star
40

wunderlist

Wunderlist notifications channel for Laravel 5.3
PHP
8
star
41

jusibe

Jusibe notifications channel for Laravel
PHP
8
star
42

cmsms

CMSMS notifications channel for Laravel
PHP
7
star
43

smspoh

Smspoh Notifications Channel for Laravel
PHP
7
star
44

workplace

Workplace notification channel for Laravel
PHP
6
star
45

sms77

Seven.io (formerly SMS77) notification channel for Laravel
PHP
6
star
46

turbosms

TurboSMS notification channel for Laravel
PHP
5
star
47

pagerduty

Laravel Notification Channel for PagerDuty
PHP
5
star
48

intercom

Intercom notifications channel for Laravel
PHP
5
star
49

infobip

Infobip notifications channel for Laravel.
PHP
4
star
50

evernote

Evernote notifications channel for Laravel 5.3
PHP
3
star
51

sipgate

Sipgate Notifications Channel for Laravel 5.5+, 6.X and 7
PHP
3
star
52

touch-sms

πŸ“² TouchSMS Notifications Channel for Laravel
PHP
3
star
53

netgsm

NetGsm notification channel for Laravel
3
star
54

pushwoosh

Pushwoosh notifications channel for Laravel
PHP
2
star
55

ovh-sms

PHP
2
star
56

46elks

46Elks notification channel for Laravel
PHP
2
star
57

todoist

Todoist notifications channel for Laravel 5.3
PHP
2
star
58

sms-broadcast

Laravel Notification Channel for Sms Broadcast
PHP
2
star
59

textlocal

PHP
2
star
60

maillift

MailLift notifications channel for Laravel 5.3
PHP
1
star
61

all-my-sms

AllMySms notification channel for Laravel
PHP
1
star
62

vodafone

Vodafone Notification Channel for Laravel
PHP
1
star