Giter Club home page Giter Club logo

pushwoosh's Introduction

Pushwoosh notification channel for Laravel

Build status Downloads Latest release Code coverage License

This package makes sending notifications using Pushwoosh a breeze.

Contents

Requirements

This make use of this package you need:

  • Laravel 5.5 or higher
  • PHP 7.0 or higher
  • An active Pushwoosh subscription

Installation

To install this package run the following command:

composer require laravel-notification-channels/pushwoosh

Next, add the following lines to your config/services.php:

'pushwoosh' => [
    'application' => env('PUSHWOOSH_APP_CODE'),
    'token' => env('PUSHWOOSH_TOKEN'),
],

You can now add the PUSHWOOSH_APP_CODE (found here) and the PUSHWOOSH_TOKEN (found here) to your environment file.

Usage

Using this package, you can use Pushwoosh just like any other notification channel within Laravel. For more information about Laravel's notification system, see the official documentation.

Routing notifications

In order for Pushwoosh to know to what devices it needs to send to, you will need to add the routeNotificationForPushwoosh to your notifiable model(s), for example:

class Customer extends Model
{
    use Notifiable;
    
    public function routeNotificationForPushwoosh()
    {
        return (new PushwooshRecipient)->device($this->device_id);
    }
}

The routeNotificationForPushwoosh method may return a string, an array of strings or a PushwooshRecipient instance. For more information about the PushwooshRecipient class refer to the available methods section.

Sending notifications

Sending a pushwoosh message is easy, add pushwoosh to your notification's via method and implement the toPushwoosh method, for example:

class WishlistItemOnSale extends Notification
{
    public function via($notifiable)
    {
        return ['pushwoosh'];
    }
    
    public function toPushwoosh($notifiable)
    {
        return (new PushwooshMessage)
            ->content('Your wishlist item ' . $this->product->name . ' is on sale, get it now!')
            ->url(route('products.show', $this->product))
            ->deliverAt(Carbon::now()->addMinutes(10));
    }
}

The toPushwoosh method may return a string or an instance of the PushwooshMessage class, for more information on the PushwooshMessage class refer to the available methods section.

Available methods

This section details the public API of this package.

PushwooshMessage

Below is a list of available methods on the PushwooshMessage class.

Method Description
campaign($campaign) Set the Pushwoosh campaign code
content($content[, $language]) Set the message content (optionally for a specific language)
deliverAt($when[, $timezone]) Set the delivery moment
identifier($identifier) Set the Pushwoosh unique identifier (defaults to the notification ID)
preset($preset) Set the Pushwoosh preset code
throttle($limit) Throttle the rollout (100-1000 pushes per second)
url($url[, $shorten]) Set the URL the message should link to
useRecipientTimezone() Respect the recipients' timezone when delivering the message

PushwooshRecipient

Below is a list of available methods on the PushwooshRecipient class.

Method Description
device($device[, ...]) Limit the delivery to the given device(s)
platform($platform[, ...]) Limit the delivery to the given platform(s)
user($user[, ...]) Limit the delivery to the given user(s)
within($lat, $lng, $range) Limit the delivery to the given geo zone
Platforms

Below is a list of supported platforms, for the PushwooshRecipient::platform method.

  • Amazon
  • Android
  • Blackberry
  • Chrome
  • Firefox
  • iOS
  • Mac
  • Safari
  • Windows
  • Windows Phone

Changelog

Please see the changelog for more information on what has changed recently.

Testing

composer test

Contributing

If you want to contribute to this package, take a look at the contribution guide.

Credits

License

This product is licensed under the MIT License (MIT). Please see the License File for more information.

pushwoosh's People

Contributors

axlon avatar atymic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.