superbalist/php-appboy

This package is abandoned and no longer maintained. No replacement package was suggested.

A PHP client for sending push notifications via the Appboy API

1.0.1 2017-06-29 11:27 UTC

This package is auto-updated.

Last update: 2022-08-11 19:49:37 UTC


README

A PHP client for sending push notifications via the Appboy API

Author Build Status StyleCI Software License Packagist Version Total Downloads

Installation

composer require superbalist/php-appboy

Usage

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

$client = new Client();
$appboy = new Appboy($client, 'your-app-group-id');

// 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()