PHPackages                             swaroop/apns2 - 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. swaroop/apns2

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

swaroop/apns2
=============

Simple &amp; expressive PHP HTTP2 API for Apple Push Notification service (APNs) with comprehensive docs/constants.

2.0.2(4y ago)027MITPHPPHP &gt;=5.4.0

Since Apr 5Pushed 4y agoCompare

[ Source](https://github.com/swaroop-at-dockare/apns2)[ Packagist](https://packagist.org/packages/swaroop/apns2)[ Docs](https://github.com/swaroop-at-dockare/apns2)[ RSS](/packages/swaroop-apns2/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)DependenciesVersions (8)Used By (0)

apns2
=====

[](#apns2)

Simple &amp; expressive PHP HTTP2 API for Apple Push Notification service (APNs) with comprehensive docs/constants.

### Guidance

[](#guidance)

1. [Make Sure CURL Supports HTTP/2](http://stackoverflow.com/a/34831873/286348) (for php version &lt; 5.5.24, check [here](https://stackoverflow.com/a/34609756))
2. [Creating a Universal Push Notification Client SSL Certificate (.p12)](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html#//apple_ref/doc/uid/TP40012582-CH26-SW11)
3. Converting .p12 to .pem

> `openssl pkcs12 -in cert.p12 -out cert.pem -nodes -clcerts`

4. Go

> `composer require swaroop/apns2`

### Usage

[](#usage)

#### using classes

[](#using-classes)

```
$connection = new Swaroop\Apns2\Connection();
$connection->sandbox = false;
$connection->certPath = '/path/to/http2/cert.pem';

$aps = new Swaroop\Apns2\MessageAPSBody();
$aps->alert = 'test 1';
$aps->sound = 'default';

$message = new Swaroop\Apns2\Message();
$message->aps = $aps;

$options = new Swaroop\Apns2\Options();
$options->apnsTopic = 'your.bundle.id';

$responses = $connection->send([
    '81fbf7e296f6c94755832a48476182e4e9586a380116e18a46531b62349504f0',
    'e2d0b464813b6b2371d745dff2b1e5fb6b83b07f7dcd98cc9f1346a7752dcc45',
], $message, $options);
$connection->close();
var_dump($responses);
```

#### using arrays

[](#using-arrays)

```
$connection = new \Swaroop\Apns2\Connection(['sandbox' => true, 'cert-path' => '/path/to/http2/cert.pem']);

$responses = $connection->send([
    '81fbf7e296f6c94755832a48476182e4e9586a380116e18a46531b62349504f1' // invalid
], [
    'aps' => [
        'alert' => 'test 2',
        'sound' => 'default',
    ]
], [
    'apns-topic' => 'your.bundle.id',
]);
$connection->close();
```

#### check response data

[](#check-response-data)

```
echo "check response: {$responses[0]->apnsId} == ${uuid}\n";
assert($responses[0]->apnsId == $uuid);

$reason = \Swaroop\Apns2\Response::REASON_BAD_DEVICE_TOKEN;
echo "check response: {$responses[0]->reason} == ${reason}\n";
assert($responses[0]->reason == $reason);
```

### License

[](#license)

MIT

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~313 days

Recently: every ~447 days

Total

7

Last Release

1494d ago

Major Versions

1.3 → 2.02022-05-14

PHP version history (2 changes)1.0PHP &gt;=5.3.0

1.3PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/118303ffe90f39fc92bc97d174193dce3736e53c4d434a6facc4802084b04be9?d=identicon)[swaroop-at-dockare](/maintainers/swaroop-at-dockare)

---

Top Contributors

[![swaroop-at-dockare](https://avatars.githubusercontent.com/u/104550179?v=4)](https://github.com/swaroop-at-dockare "swaroop-at-dockare (9 commits)")[![huxia](https://avatars.githubusercontent.com/u/228669?v=4)](https://github.com/huxia "huxia (3 commits)")

---

Tags

phppushhttp2notificationSimpleappleapns

### Embed Badge

![Health badge](/badges/swaroop-apns2/health.svg)

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

###  Alternatives

[sly/notification-pusher

Standalone PHP library for easy devices notifications push.

1.2k2.8M16](/packages/sly-notification-pusher)[m2mobi/apns-php

Apple Push Notification &amp; Feedback Provider

1118.3k1](/packages/m2mobi-apns-php)

PHPackages © 2026

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