2017 © Pedro Peláez
 

library unified-push

Unified Push supports push notifications for iOS, Android and Windows Phone devices via APNs, GCM and MPNS

image

zbox/unified-push

Unified Push supports push notifications for iOS, Android and Windows Phone devices via APNs, GCM and MPNS

  • Thursday, September 29, 2016
  • by zbox
  • Repository
  • 3 Watchers
  • 10 Stars
  • 136 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 6 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Unified Push

Scrutinizer Code Quality, (*1)

Unified Push supports push notifications for iOS, Android and Windows Phone devices via APNs, GCM and MPNS., (*2)

Wiki: UML structure and sequence diagrams., (*3)

Install

The recommended way to install UnifiedPush is through composer., (*4)

{
    "require": {
        "zbox/unified-push": "^0.9"
    }
}

Features

  • Unified interface that supports sending push notifications for platforms:
    • Apple (APNS)
    • Android (GCM)
    • Windows Phone (MPNS)

Requirements

  • PHP 5.3.2 or later
  • HTTP client (kriswallsmith/buzz)
  • PSR Log (psr/log)
  • PHPUnit to run tests

Usage

Configure Notification Services Client Factory

Create service client factory configured with credentials., (*5)

<?php

use Zbox\UnifiedPush\NotificationService\ServiceClientFactory;
use Zbox\UnifiedPush\NotificationService\ServiceCredentialsFactory;
use Zbox\UnifiedPush\Utils\ClientCredentials\CredentialsMapper;

$credentialsFactory = 
    new ServiceCredentialsFactory(
        new CredentialsMapper()
    );

$credentials = ['certificate' => 'path', 'certificatePassPhrase' => 'pass'];
$credentialsFactory->addCredentialsForService('APNS', $credentials);

$clientFactory = new ServiceClientFactory($credentialsFactory);
$clientFactory->setDefaultConfigPath();

Initialize Message Dispatcher

Initialize class with client factory, notification builder and response handler., (*6)

<?php

use Zbox\UnifiedPush\Dispatcher;
use Zbox\UnifiedPush\Notification\NotificationBuilder;
use Zbox\UnifiedPush\NotificationService\ResponseHandler;

$dispatcher =
    new Dispatcher(
        $clientFactory,
        new NotificationBuilder(),
        new ResponseHandler()
    );

$dispatcher->setDevelopmentMode(true);

Create messages

Create messages of type APNS, GCM, MPNS (Raw, Tile or Toast)., (*7)

<?php

use Zbox\UnifiedPush\Message\MessageCollection;
use Zbox\UnifiedPush\Message\Type\APNS as APNSMessage;
use Zbox\UnifiedPush\Message\Type\APNSAlert;
use Zbox\UnifiedPush\Message\Type\GCM as GCMMessage;

$message1 = new APNSMessage();
$message1
    ->setAlertDictionary(
        (new APNSAlert)
            ->setActionLocKey('btn')
            ->setLocKey('msg')
            ->setLocArgs([$args])
    )
    ->setSound('alert')
    ->getBadge('2');

$message1->addRecipient('deviceToken1');

$message2 = new GCMMessage();
$message2
    ->setCollapseKey('key')
    ->addRecipientIdentifiers(
       new \ArrayIterator([
            'deviceToken1', 
            'deviceToken2'
        ])
    )
    ->setPayloadData([
        'keyA' => 'value1',
        'keyB' => 'value2',
    ]);

$messages = 
    new MessageCollection([
        $message1, 
        $message2
    ]);

Dispatch messages

Send messages and load feedback., (*8)

<?php

$dispatcher
    ->dispatchAll($messages)
    ->loadFeedback();

Status

Handle responses to see a report on dispatch errors., (*9)

<?php

$responseHandler = $dispatcher->getResponseHandler();
$responseHandler->handleResponseCollection();

$invalidRecipients  = $responseHandler->getInvalidRecipients();
$messageErrors      = $responseHandler->getMessageErrors();

License

MIT, see LICENSE., (*10)

The Versions

29/09 2016

dev-master

9999999-dev https://github.com/zbox/UnifiedPush

Unified Push supports push notifications for iOS, Android and Windows Phone devices via APNs, GCM and MPNS

  Sources   Download

MIT

The Requires

 

by Alexander Zhukov

message notification apple push gcm apns android windows phone iphone mpns apn

29/09 2016

0.9.2

0.9.2.0 https://github.com/zbox/UnifiedPush

Unified Push supports push notifications for iOS, Android and Windows Phone devices via APNs, GCM and MPNS

  Sources   Download

MIT

The Requires

 

by Alexander Zhukov

message notification apple push gcm apns android windows phone iphone mpns apn

31/08 2016

0.9.1

0.9.1.0 https://github.com/zbox/UnifiedPush

Unified Push supports push notifications for iOS, Android and Windows Phone devices via APNs, GCM and MPNS

  Sources   Download

MIT

The Requires

 

by Alexander Zhukov

message notification apple push gcm apns android windows phone iphone mpns apn

09/07 2016

dev-php7-support

dev-php7-support https://github.com/zbox/UnifiedPush

Unified Push supports push notifications for iOS, Android and Windows Phone devices via APNs, GCM and MPNS

  Sources   Download

MIT

The Requires

 

by Alexander Zhukov

message notification apple push gcm apns android windows phone iphone mpns apn

05/07 2016

0.9

0.9.0.0 https://github.com/zbox/UnifiedPush

Unified Push supports push notifications for iOS, Android and Windows Phone devices via APNs, GCM and MPNS

  Sources   Download

MIT

The Requires

 

by Alexander Zhukov

message notification apple push gcm apns android windows phone iphone mpns apn

30/03 2016

0.9-rc.1

0.9.0.0-RC1 https://github.com/zbox/UnifiedPush

Unified Push supports push notifications for iOS, Android and Windows Phone devices via APNs, GCM and MPNS

  Sources   Download

MIT

The Requires

 

by Alexander Zhukov

message notification apple push gcm apns android windows phone iphone mpns apn