This package makes it easy to send Pushmix notifications with Laravel 6
- Setting up your Pushmix account
- Installation
- Displaying Opt In Prompt
- Usage
- Changelog
- Testing
- Issues
- Security Vulnerabilities
- Contributing
- Credits
- License
If you haven't already, sign up for a free account on pushmix.co.uk.
Create new subscription for your website and choose preferred integration method. Build your subscribers audience via displaying an Opt-In Prompt asking users for permission to send them push notifications.
You can install the package via composer:
$ composer require pushmix/laravel-web-notification:dev-master
If you're installing the package in Laravel 5.4 or lower, you must import the service provider:
// config/app.php
'providers' => [
...
Pushmix\WebNotification\PushmixServiceProvider::class,
],
Publish package config and view files:
php artisan vendor:publish --provider="Pushmix\WebNotification\PushmixServiceProvider"
Add your Subscription ID into .env
file:
PUSHMIX_SUBSCRIPTION_ID=PASTE_YOUR_SUBSCRIPTION_ID_HERE
To display Opt-In Prompt you will need to include block of JavaScript into your template using Blade @include
directive.
Alternatively you can copy and paste content of vendor.pushmix.optin
into template.
<body>
...
<div class="content">
<div class="title m-b-md">
Laravel
</div>
</div>
<!-- Including Opt In Prompt in Blade template-->
@include('vendor.pushmix.optin')
</body>
...
Now you can use the channel in your via()
method inside the notification:
use Pushmix\WebNotification\PushmixChannel;
use Pushmix\WebNotification\PushmixMessage;
use Illuminate\Notifications\Notification;
class AbandonedCart extends Notification
{
public function via($notifiable)
{
return [PushmixChannel::class];
}
public function toPushmix($to)
{
return PushmixMessage::create($to)
/* Required Parameters */
->title("You still have items in your Cart!")
->body("There's still time to complete your order. Return to your cart?")
->url("https://www.pushmix.co.uk")
/* Optional Parameters */
->button("Return to your cart", "https://www.pushmix.co.uk/docs") // button one
->priority("high")
->ttl(7200) // time to live
->icon("https://www.pushmix.co.uk/media/favicons/apple-touch-icon.png")
->badge("https://www.pushmix.co.uk/media/favicons/pm_badge_v2.png")
->image("https://www.pushmix.co.uk/media/photos/photo16.jpg");
}
}
The notifications will be sent to the audience, which subscribed via Opt-In Prompt displayed on your website.
Using the Notification::route
method, you can specify which subscribers group you are targeting.
use Notification;
use App\Notifications\AbandonedCart;
...
// Target All Subscribed Users
Notification::route('Pushmix', 'all')->notify(new AbandonedCart());
// Target Topic One Subscribers
Notification::route('Pushmix', 'one')->notify(new AbandonedCart());
// Target Topic Two Subscribers
Notification::route('Pushmix', 'two')->notify(new AbandonedCart());
-
title('')
: Accepts a string value for the title, required* -
body('')
: Accepts a string value for the notification body,required* -
url('')
: Accepts an url for the notification click event,required* -
button('', '')
: Accepts string value for button title and an url for the notification click event. Max 2 buttons can be attached. -
icon('')
: Accepts an url for the icon. -
priority('')
: Acceptshigh
ornormal
strings. -
ttl('')
: Accepts an integer, notification life span in seconds,must be from 0 to 2,419,200 -
icon('')
: Accepts an url for the icon. -
badge('')
: Accepts an url for the badge. -
image('')
: Accepts an url for the large image.
Navigate into the package folder vendor/pushmix/laravel-web-notification
and issue following command:
$ composer test
If you come across any issues please report them here.
If you discover a security vulnerability please send an e-mail to support@pushmix.co.uk.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.