2017 © Pedro Peláez
 

library pusher-push-notifications

image

pusher/pusher-push-notifications

  • Tuesday, July 31, 2018
  • by pusher
  • Repository
  • 5 Watchers
  • 3 Stars
  • 2,492 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 20 Versions
  • 38 % Grown

The README.md

Build Status, (*1)

PHP SDK for Pusher Beams

PHP server library for publishing notifications through Pusher Beams., (*2)

Check https://docs.pusher.com/beams/reference/server-sdk-php for more information., (*3)

NOTE: This library requires a PHP version of 8.0 or greater, (*4)

Installation

Get Composer, then get the pusher/pusher-push-notifications Composer package:, (*5)

$ composer require pusher/pusher-push-notifications

This SDK depends on the JSON PHP module., (*6)

Use

Configuring the SDK for your instance

<?php
require __DIR__ . '/vendor/autoload.php';

$pushNotifications = new \Pusher\PushNotifications\PushNotifications(array(
  "instanceId" => "YOUR_INSTANCE_ID_HERE",
  "secretKey" => "YOUR_SECRET_HERE",
));

Publishing to Device Interests

You can broadcast notifications to groups of subscribed devices using Device Interests:, (*7)

$publishResponse = $pushNotifications->publishToInterests(
  ["donuts"],
  [
    "apns" => [
      "aps" => [
        "alert" => "Hello!",
      ],
    ],
    "fcm" => [
      "notification" => [
        "title" => "Hello!",
        "body" => "Hello, world!",
      ],
    ],
  ]
);

echo("Published with Publish ID: " . $publishResponse->publishId . "\n");

Publishing to Device Interests along with data

You can broadcast notifications with some data to groups of subscribed devices using Device Interests:, (*8)

$publishResponse = $pushNotifications->publishToInterests(
  ["donuts"],
  [
    "apns" => [
      "aps" => [
        "alert" => "Hello!",
      ],
    ],
    "fcm" => [
      "notification" => [
        "title" => "Hello!",
        "body" => "Hello, world!",
      ],
      "data" => [
         "name" => "adam",
         "type" => "user",
      ],
    ],
  ]
);

echo("Published with Publish ID: " . $publishResponse->publishId . "\n");

Publishing to Authenticated Users

Securely send notifications to individual users of your application using Authenticated Users:, (*9)

$publishResponse = $pushNotifications->publishToUsers(
  ["user-0001"],
  [
    "apns" => [
      "aps" => [
        "alert" => "Hello!",
      ],
    ],
    "fcm" => [
      "notification" => [
        "title" => "Hello!",
        "body" => "Hello, world!",
      ],
    ],
  ]
);

echo("Published with Publish ID: " . $publishResponse->publishId . "\n");

The Versions

31/07 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

31/07 2018

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

31/07 2018

dev-bump-ga-release

dev-bump-ga-release

  Sources   Download

MIT

The Requires

 

The Development Requires

31/07 2018

dev-add-usage-to-readme

dev-add-usage-to-readme

  Sources   Download

MIT

The Requires

 

The Development Requires

31/07 2018

dev-add-changelog

dev-add-changelog

  Sources   Download

MIT

The Requires

 

The Development Requires

12/07 2018

0.10.8

0.10.8.0

  Sources   Download

MIT

The Requires

 

The Development Requires

10/07 2018

0.10.7

0.10.7.0

  Sources   Download

MIT

The Requires

 

The Development Requires

09/07 2018

dev-semicolon

dev-semicolon

  Sources   Download

MIT

The Requires

 

The Development Requires

29/05 2018

dev-beams-readme-update

dev-beams-readme-update

  Sources   Download

MIT

The Requires

 

The Development Requires

20/04 2018

0.10.6

0.10.6.0

  Sources   Download

MIT

The Requires

 

The Development Requires

29/03 2018

0.10.5

0.10.5.0

  Sources   Download

MIT

28/03 2018

dev-better-validation

dev-better-validation

  Sources   Download

MIT

15/03 2018

0.10.4

0.10.4.0

  Sources   Download

MIT

15/03 2018

0.10.3

0.10.3.0

  Sources   Download

MIT

12/03 2018

0.10.2

0.10.2.0

  Sources   Download

MIT

20/02 2018

0.10.1

0.10.1.0

  Sources   Download

MIT

19/02 2018

dev-validate-empty-string

dev-validate-empty-string

  Sources   Download

MIT

08/01 2018

0.10.0

0.10.0.0

  Sources   Download

MIT

02/01 2018

0.9.1

0.9.1.0

  Sources   Download

MIT

12/12 2017

0.9.0

0.9.0.0

  Sources   Download

MIT