PHPackages                             mrdanshur/awspushbundle - 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. mrdanshur/awspushbundle

ActiveSymfony-bundle[Mail &amp; Notifications](/categories/mail)

mrdanshur/awspushbundle
=======================

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

1.0.1(3y ago)03.4kMITPHPPHP &gt;=7.4

Since Mar 30Pushed 3y agoCompare

[ Source](https://github.com/MrDanshur/awspushbundle)[ Packagist](https://packagist.org/packages/mrdanshur/awspushbundle)[ RSS](/packages/mrdanshur-awspushbundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (17)Versions (4)Used By (0)

Aws Push Bundle
===============

[](#aws-push-bundle)

A convenient bundle for registering devices and then pushing to them using amazons SNS service.

[![Latest Stable Version](https://camo.githubusercontent.com/b246e2cd1118c845cbe9350d793305f911ea5383bb9ba68aef038cf9b13a954e/68747470733a2f2f706f7365722e707567782e6f72672f6d63666564722f6177737075736862756e646c652f762f737461626c652e706e67)](https://packagist.org/packages/mcfedr/awspushbundle)[![License](https://camo.githubusercontent.com/ef28ed197b1b31ee410e9e59444ee2fa6bd9250ff7df38c8c63276ebd321a927/68747470733a2f2f706f7365722e707567782e6f72672f6d63666564722f6177737075736862756e646c652f6c6963656e73652e706e67)](https://packagist.org/packages/mcfedr/awspushbundle)[![Build Status](https://camo.githubusercontent.com/57cc8679d99f53ec2ef35de788ca2e2e1c33834f62aaa4846dbd4b4d667226ec/68747470733a2f2f7472617669732d63692e6f72672f6d63666564722f6177737075736862756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mcfedr/awspushbundle)

Install
-------

[](#install)

### Composer

[](#composer)

```
php composer.phar require mcfedr/awspushbundle

```

### AppKernel

[](#appkernel)

Include the bundle in your AppKernel

```
public function registerBundles()
{
    $bundles = array(
        ...
        new Mcfedr\AwsPushBundle\McfedrAwsPushBundle()

```

Config
------

[](#config)

Put something like this in your config. The arns in the platforms section should be the preconfigured app arns in SNS.

```
mcfedr_aws_push:
    platforms:
        ios: 'arn:aws:sns:....'
        android: 'arn:aws:sns:....'
    topic_arn: 'arn:aws:sns:...'
    pushPlatforms: [apns, fcm]
    aws:
        credentials:
            key: 'my key'
            secret: 'my secret'
        region: 'my region'

```

You can skip `credentials` if you have want the Aws SDK to get credentials indirectly, either from [environment](https://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html#environment-credentials) or [ec2 role](https://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html#using-iam-roles-for-amazon-ec2-instances).

If you don't set the `pushPlatforms` setting then android messages will sent in a format compatible with GCM, i.e. the `notification` field will not be set. This is for backwards compatibility of this bundle.

Usage
-----

[](#usage)

Basically have a look at how the ApiController does its stuff

1. Register the device token

    ```
     $arn = $this->get('mcfedr_aws_push.devices')->registerDevice($token, $platform)

    ```
2. Send message to one device

    ```
     $this->get('mcfedr_aws_push.messages')->send($message, $arn)

    ```
3. Send message to all devices

    ```
     $this->get('mcfedr_aws_push.messages')->broadcast($message)

    ```

Alternative usage, using topics to send messages to lots of devices

1. Register the device token

    ```
     $arn = $this->get('mcfedr_aws_push.devices')->registerDevice($token, $platform)

    ```
2. Register the device on the topic

    ```
     $this->get('mcfedr_aws_push.topics')->registerDeviceOnTopic($arn, $topicArn)

    ```
3. Send messages

    ```
     $this->get('mcfedr_aws_push.topics')->broadcast($message, $topicArn)

    ```

If you later add a topic\_name to the configuration you can run the `mcfedr:aws:subscribe` command to add your existing devices to the topic.

Text in notifications
---------------------

[](#text-in-notifications)

For GCM and ADM there is no 'standard' key for text data as there is for Apple pushes, so this bundle send text in a key called `message`.

If localized text is sent the keys are

- `message-loc-key`
- `message-loc-args`

'Complicated' data on ADM
-------------------------

[](#complicated-data-on-adm)

ADM only allows strings as values in the push data. This bundle lets you send 'complicated' values and will automatically json encode these values for ADM. When it does this the key has `_json` added so that its easy to handle this on the app side.

### Example

[](#example)

Sending:

```
$message = new Message();
$message->setCustom(['simple' => 'Hello', 'complicated' => ['inner' => 'value']]);

```

ADM received data:

```
{"data": {"simple": "Hello", "complicated_json": "{\"inner\":\"value\"}"}}

```

To handle this data you should detect keys that end with `_json` and decode the values

**The applies to `message-loc-args` as well, they will always come as `message-loc-args_json` via ADM**

Commands
--------

[](#commands)

There are some commands to help manage the devices

1. `mcfedr:aws:enable`

    This will reenable all the devices
2. `mcfedr:aws:remove`

    This will remove any disabled devices. Its a good idea to do something like this regularly to remove old devices
3. `mcfedr:aws:subscribe`

    This will subscribe all devices to a topic, useful when introducing a topic

Api Controller
--------------

[](#api-controller)

**Optional.**

There is a controller included which makes basic usage of the bundle very easy. You may or may not want to use it, you might find it most useful as an example.

There are some extra dependencies you must add when using the controller

- sensio/framework-extra-bundle
- symfony/validator
- symfony/serializer
- symfony/property-info
- symfony/security-bundle
- symfony/expression-language

They also need enabling in the framework config

```
framework:
    validation: { enable_annotations: true }
    serializer:
        enabled: true
    property_info:
        enabled: true
```

Add the routes in your `routing.yaml`:

```
mcfedr_aws_push:
    resource: "@McfedrAwsPushBundle/Controller/"
    type:     annotation
    prefix:   /

```

### Usage

[](#usage-1)

The controller provides two urls, both expect a JSON POST body

1. The first is a way to register a device

    ```
     POST /devices
     {
         "device": {
             "deviceId": "a push token",
             "platform": "the platform name in your config file"
         }
     }

    ```
2. The second is a way to send a broadcast message. If you are using a topic for all devices then don't send the platform parameter.

    ```
     POST /broadcast
     {
         "broadcast": {
             "platform": "ios"
             "message": {
                 "text": "The plain text message to send",
                 "badge": 1
             }
         }
     }

    ```

More info
---------

[](#more-info)

- [Apple Push Notifcation Reference](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification)
- [FCM](https://firebase.google.com/docs/cloud-messaging/http-server-ref)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 82.1% 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 ~0 days

Total

2

Last Release

1137d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7334a9b351493a80d23ed1aedc5f8afc074f8dbca7a4c1db5d65754c892e92c?d=identicon)[MrDanshur](/maintainers/MrDanshur)

---

Top Contributors

[![mcfedr](https://avatars.githubusercontent.com/u/704356?v=4)](https://github.com/mcfedr "mcfedr (160 commits)")[![nonanerz](https://avatars.githubusercontent.com/u/19575167?v=4)](https://github.com/nonanerz "nonanerz (9 commits)")[![javer](https://avatars.githubusercontent.com/u/591296?v=4)](https://github.com/javer "javer (8 commits)")[![deguif](https://avatars.githubusercontent.com/u/993399?v=4)](https://github.com/deguif "deguif (6 commits)")[![ahonymous](https://avatars.githubusercontent.com/u/4721334?v=4)](https://github.com/ahonymous "ahonymous (3 commits)")[![dylan-salmon](https://avatars.githubusercontent.com/u/80682727?v=4)](https://github.com/dylan-salmon "dylan-salmon (3 commits)")[![ayoze](https://avatars.githubusercontent.com/u/1452175?v=4)](https://github.com/ayoze "ayoze (2 commits)")[![avtehnik](https://avatars.githubusercontent.com/u/3436529?v=4)](https://github.com/avtehnik "avtehnik (2 commits)")[![Etheriq](https://avatars.githubusercontent.com/u/5667027?v=4)](https://github.com/Etheriq "Etheriq (1 commits)")[![MrDanshur](https://avatars.githubusercontent.com/u/5676518?v=4)](https://github.com/MrDanshur "MrDanshur (1 commits)")

---

Tags

symfonybundleamazonawspushnotificationgcmFCMSNSapnsc2dmios

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mrdanshur-awspushbundle/health.svg)

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

###  Alternatives

[mcfedr/awspushbundle

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

40378.6k1](/packages/mcfedr-awspushbundle)

PHPackages © 2026

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