PHPackages                             juliangut/tify - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. juliangut/tify

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

juliangut/tify
==============

Unified push notification services abstraction

1.2(9y ago)0177BSD-3-ClausePHPPHP &gt;=5.5

Since Dec 4Pushed 9y ago1 watchersCompare

[ Source](https://github.com/juliangut/tify)[ Packagist](https://packagist.org/packages/juliangut/tify)[ Docs](http://github.com/juliangut/tify)[ RSS](/packages/juliangut-tify/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (5)Dependencies (11)Versions (16)Used By (0)

[![PHP version](https://camo.githubusercontent.com/8c508dbfb530cc5703d088796f65f3230e83d32a68e84c73bc9e7847b12a0fa7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344352e352d3838393242462e7376673f7374796c653d666c61742d737175617265)](http://php.net)[![Latest Version](https://camo.githubusercontent.com/fbb681911950e7e4d581647a7eafea4a2f2502c82e81a77652ff60d2f377ba14/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f6a756c69616e6775742f746966792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/juliangut/tify)[![License](https://camo.githubusercontent.com/6b1805429fdae07f40e2d84fa48ee011d98c95816b72114cf47e43350d4db84e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a756c69616e6775742f746966792e7376673f7374796c653d666c61742d737175617265)](https://github.com/juliangut/tify/blob/master/LICENSE)

[![Build status](https://camo.githubusercontent.com/56ee54825550fca59ec976d0476e7f13571b5b38d48a62c5865190745755e2f9/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6a756c69616e6775742f746966792e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/juliangut/tify)[![Style](https://camo.githubusercontent.com/f24ab723ec305207a283cacb1158d450c47e5059ab0e5549ba93ffadaf8164ed/68747470733a2f2f7374796c6563692e696f2f7265706f732f34373237353130372f736869656c64)](https://styleci.io/repos/47275107)[![Code Quality](https://camo.githubusercontent.com/0b5f9358755438e4c67dd82f953ca63fbcc7b83e6137c0d02c044f80feb8d02f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6a756c69616e6775742f746966792e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/juliangut/tify)[![Code Coverage](https://camo.githubusercontent.com/b9e1e44b4978a64614f2827cba6bff163023dfd9a733d0c79ca2ef83e4b27624/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6a756c69616e6775742f746966792e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/juliangut/tify)[![Total Downloads](https://camo.githubusercontent.com/6e358b066e5ea9891b216c8b0dbe9314767d6ae68fd0d466870cfec03c4d6f20/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a756c69616e6775742f746966792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/juliangut/tify)

Tify
====

[](#tify)

Unified push notification services abstraction layer to connect with Google GCM and Apple APNS services.

Installation
------------

[](#installation)

Install using Composer:

```
composer require juliangut/tify

```

Then require\_once the autoload file:

```
require_once './vendor/autoload.php';
```

Concepts
--------

[](#concepts)

### Receiver

[](#receiver)

Each of the individual devices that will receive push notification. Identified by a device `token` provided by push notification service (APNS or GCM).

```
new \Jgut\Tify\Receiver\ApnsReceiver('device_token');
new \Jgut\Tify\Receiver\GcmReceiver('device_token');
```

`device_token` follow different formats depending on service type. Review APNS and GCM documentation for proper formatting.

### Message

[](#message)

Messages compose the final information arriving to receivers. GCM and APNS messages hold different information according to each service specification.

In order for the message payload to be created one of the following message parameters must be present:

- For APNS
    - `title`
    - `title_loc_key`
    - `body`
    - `loc_key`
- For GCM
    - `title`
    - `title_loc_key`
    - `body`
    - `body_loc_key`

Messages can hold any number of custom payload data that will compose additional data sent to the destination receivers.

This key/value payload data must comply with some limitations to be fully compatible with different services at once, for this a prefix (`data_` by default) is automatically added to the key. This prefix can be changed or removed if needed, but be aware that payload data should not be a reserved word (`aps`, `from` or any word starting with `google` or `gcm`) or any GCM notification parameters.

*Find APNS message parameters [here](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html) in table 3-2.*

*Find GCM message parameters [here](https://developers.google.com/cloud-messaging/http-server-ref#table2) in table 2.*

### Notification

[](#notification)

It's a container to keep a message and its associated destination receivers.

Notifications are the central unit of work, several notifications can be set into a Tify Service sharing the same adapters but sending different messages to different receivers.

Notifications hold some extra parameters used by the push notification services to control behaviour and/or be used in notification creation.

By clearing receivers list or changing message a notification can be reused as many times as needed.

*Find APNS notification parameters [here](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html) in table 3-1.*

*Find GCM notification parameters [here](https://developers.google.com/cloud-messaging/http-server-ref#table1) in table 1.*

### Adapter

[](#adapter)

Adapters will be given notifications to actually send the messages to associated receivers using the corresponding notification service. Receivers will be automatically filtered for the correct service by their type.

For APNS adapter `certificate` parameter is mandatory, denoting the path to the service certificate (.pem file). In GCM `api_key` is the mandatory parameter denoting Google API key.

```
$apnsService = new \Jgut\Tify\Service\ApnsService(['certificate' => 'path_to_certificate.pem']);
$gcmService = new \Jgut\Tify\Service\GcmService(['api_key' => 'google_api_key']);
```

### Result

[](#result)

Responses from APNS and GCM push services are very different from one another, Result is a response abstraction in order to provide a common interface to access this non-equal returning data from APNS and GCM services.

This objects are composed of device token, date, status code (a status categorization) and status message (which corresponds to the original APNS or GCM response status).

#### Status Codes

[](#status-codes)

- `STATUS_SUCCESS`, push was successful
- `STATUS_INVALID_DEVICE`, device token provided is invalid
- `STATUS_INVALID_MESSAGE`, message was not properly composed
- `STATUS_RATE_ERROR`, only for GCM
- `STATUS_AUTH_ERROR`, only for GCM
- `STATUS_SERVER_ERROR`
- `STATUS_UNKNOWN_ERROR`

Among all the result statuses, `STATUS_INVALID_DEVICE` is the most interesting because it is a signal that you should probably remove that token from your database.

### Service

[](#service)

For simplicity instead of handing notifications to adapters one by one 'Tify Service' can be used to send Notifications to its corresponding receivers using correct provided Adapters, automatically merging notification Results into a single returned array.

Usage
-----

[](#usage)

### Push

[](#push)

Basic usage creating a one message to be sent through different adapters.

```
use Jgut\Tify\Adapter\Apns\ApnsAdapter;
use Jgut\Tify\Adapter\Gcm\GcmAdapter;
use Jgut\Tify\Message;
use Jgut\Tify\Notification;
use Jgut\Tify\Receiver\ApnsReceiver;
use Jgut\Tify\Receiver\GcmReceiver;
use Jgut\Tify\Service;

$adapters = [
    new GcmAdapter(['api_key' => '00000']),
    new ApnsAdapter(['certificate' => 'path_to_certificate']),
];

$message = new Message([
    'title' => 'title',
    'body' => 'body',
]);

$receivers = [
    new GcmReceiver('aaaaaaaaaaa'),
    new GcmReceiver('bbbbbbbbbbb'),
    new ApnsReceiver('ccccccccccc'),
    new ApnsReceiver('ddddddddddd'),
];

$service = new Service($adapters, new Notification($message, $receivers));

$results = $service->push();
```

Sharing the same adapters to send different messages

```
use Jgut\Tify\Adapter\Gcm\GcmAdapter;
use Jgut\Tify\Message;
use Jgut\Tify\Notification;
use Jgut\Tify\Receiver\GcmReceiver;
use Jgut\Tify\Service;

$adapters = [
    new GcmAdapter(['api_key' => '00000']),
    new GcmAdapter(['api_key' => '11111']),
];

$service = new Service($adapters);

$service->addNotification(new Notification(
    new Message([
        'title' => 'title_one',
        'body' => 'body_one',
    ]),
    [
        new GcmReceiver('aaaaaaaaaaa'),
        new GcmReceiver('bbbbbbbbbbb'),
    ]
));

$service->addNotification(new Notification(
    new Message([
        'title' => 'title_two',
        'body' => 'body_two',
    ]),
    [
        new GcmReceiver('xxxxxxxxxxx'),
        new GcmReceiver('zzzzzzzzzzz'),
    ]
));

$results = $service->push();
```

### Feedback

[](#feedback)

```
use Jgut\Tify\Adapter\Gcm\ApnsAdapter;
use Jgut\Tify\Service;

$adapters = [
    new ApnsAdapter(['certificate' => 'path_to_certificate_one']),
    new ApnsAdapter(['certificate' => 'path_to_certificate_two']),
];

$service = new Service($adapters);

$results = $service->feedback();
```

Feedback returns Result objects with token and time of expired device tokens.

Contributing
------------

[](#contributing)

Found a bug or have a feature request? [Please open a new issue](https://github.com/juliangut/tify/issues). Have a look at existing issues before.

See file [CONTRIBUTING.md](https://github.com/juliangut/tify/blob/master/CONTRIBUTING.md)

License
-------

[](#license)

See file [LICENSE](https://github.com/juliangut/tify/blob/master/LICENSE) included with the source code for a copy of the license terms.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~31 days

Recently: every ~49 days

Total

14

Last Release

3446d ago

Major Versions

0.3 → 1.0-RC12016-05-06

1.2 → 2.0-RC12016-10-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c50421f1ab4148354dc2dd5dcaba168656b17ea913b310d112deb39a6f73ca1?d=identicon)[juliangut](/maintainers/juliangut)

---

Top Contributors

[![juliangut](https://avatars.githubusercontent.com/u/1104131?v=4)](https://github.com/juliangut "juliangut (116 commits)")

---

Tags

abstractionpushnotificationgcmapns

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/juliangut-tify/health.svg)

```
[![Health](https://phpackages.com/badges/juliangut-tify/health.svg)](https://phpackages.com/packages/juliangut-tify)
```

###  Alternatives

[sly/notification-pusher

Standalone PHP library for easy devices notifications push.

1.2k2.8M16](/packages/sly-notification-pusher)[mcfedr/awspushbundle

A set of services to simplify using Aws to send push notifications

40382.7k1](/packages/mcfedr-awspushbundle)[turbo124/laravel-push-notification

Laravel package to send push notifications to mobile devices (apns, gcm)

1158.0k](/packages/turbo124-laravel-push-notification)[witty/laravel-push-notification

Laravel 5 Package for sending push notifications to Android and iOS devices

245.0k](/packages/witty-laravel-push-notification)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
