Git Product home page Git Product logo

laravel-appboy's Introduction

laravel-appboy

A Laravel library for sending push notifications via the Appboy API

Author Build Status StyleCI Software License Packagist Version Total Downloads

This package is a wrapper bridging php-appboy into Laravel.

Installation

composer require superbalist/laravel-appboy

Register the service provider in app.php

'providers' => [
    // ...
    Superbalist\LaravelAppboy\AppboyServiceProvider::class,
]

Register the facade in app.php

'aliases' => [
    // ...
    'Appboy' => Superbalist\LaravelAppboy\AppboyFacade::class,
]

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

APPBOY_APP_GROUP_ID=null
APPBOY_API_URI=https://api.appboy.com

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

php artisan vendor:publish --provider="Superbalist\LaravelAppboy\AppboyServiceProvider"

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

Usage

use Appboy;
use Superbalist\Appboy\NotificationBuilder;
use Superbalist\Appboy\ScheduledNotificationBuilder;
use Superbalist\Appboy\Messages\AndroidMessageBuilder;
use Superbalist\Appboy\Messages\AppleMessageBuilder;

// send a push message
Appboy::sendMessage(
    (new NotificationBuilder())
        ->toUsers([1, 2])
        ->setCampaign('my_campaign')
        ->ignoreFrequencyCapping()
        ->setSubscriptionState('opted_in')
        ->withMessages([
            'apple_push' => (new AppleMessageBuilder())
                ->setAlert('Hello World!')
                ->setSound('custom_sound')
                ->withExtraAttributes(['is_test' => true])
                ->setCategory('shipping_notification')
                ->expiresAt(new \DateTime('2017-05-29 10:00:00', new \DateTimeZone('Africa/Johannesburg')))
                ->setUri('http://superbalist.com')
                ->setMessageVariation('group_a')
                ->setAsset('file://image.jpg', 'jpg')
                ->build(),
            'android_push' => (new AndroidMessageBuilder())
                ->setAlert('Hello World!')
                ->setTitle('Message Title')
                ->withExtraAttributes(['is_test' => true])
                ->setMessageVariation('group_a')
                ->setPriority(2)
                ->setCollapseKey('shipment_1234')
                ->setSound('custom_sound')
                ->setUri('http://superbalist.com')
                ->setSummaryText('This is a summary line')
                ->setTimeToLive(60)
                ->setNotificationId(18456)
                ->setPushIconImageUrl('http://link/to/asset.jpg')
                ->setAccentColour(16777215)
                ->build(),
        ])
        ->build()
);

// schedule a push message
Appboy::scheduleMessage(
    (new ScheduledNotificationBuilder())
        ->toUsers([1, 2])
        ->setCampaign('my_campaign')
        ->ignoreFrequencyCapping()
        ->setSubscriptionState('opted_in')
        ->withMessage(
            'apple_push',
            (new AppleMessageBuilder())
                ->setAlert('Hello World!')
                ->setSound('custom_sound')
                ->withExtraAttributes(['is_test' => true])
                ->setCategory('shipping_notification')
                ->expiresAt(new \DateTime('2017-05-29 10:00:00', new \DateTimeZone('Africa/Johannesburg')))
                ->setUri('http://superbalist.com')
                ->setMessageVariation('group_a')
                ->setAsset('file://image.jpg', 'jpg')
                ->build()
        )
        ->sendsAt(new \DateTime('2017-05-29 10:00:00', new \DateTimeZone('Africa/Johannesburg')))
        ->build()

laravel-appboy's People

Contributors

matthewgoslett 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.