/laravel-localytics-push

A Laravel library for sending push notifications via the Localytics Push Notification service

Primary LanguagePHPMIT LicenseMIT

laravel-localytics-push

A Laravel library for sending push notifications via the Localytics Push Notification service

Author Build Status StyleCI Software License Packagist Version Total Downloads

This package is a wrapper bridging php-localytics-push into Laravel.

Installation

composer require superbalist/laravel-localytics-push

The package has a default configuration which uses the following environment variables.

LOCALYTICS_APP_ID=null
LOCALYTICS_API_KEY=null
LOCALYTICS_API_SECRET=null

To customize the configuration file, publish the package configuration using Artisan.

php artisan vendor:publish --provider="Superbalist\LaravelLocalyticsPush\LocalyticsServiceProvider"

You can then edit the generated config at app/config/localytics.php.

Register the service provider in app.php

'providers' => [
    // ...
    Superbalist\LaravelLocalyticsPush\LocalyticsServiceProvider::class,
]

Register the facade in app.php

'aliases' => [
    // ...
    'Localytics' => Superbalist\LaravelLocalyticsPush\LocalyticsFacade::class,
]

Usage

$message = [
    'target' => [
        'profile' => [
            'criteria' => [
                [
                    'key' => '$email',
                    'scope' => 'Organization',
                    'type' => 'string',
                    'op' => 'in',
                    'values' => [
                        'matthew@superbalist.com',
                    ]
                ]
            ],
            'op' => 'and',
        ],
    ],
    'alert' => [
        'title' => 'Message Title',
        'body' => 'This is my message content!',
    ]
];
Localytics::pushMessage('profile', $message);