2017 © Pedro Peláez
 

symfony-bundle awspushbundle

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

image

mcfedr/awspushbundle

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

  • Monday, March 12, 2018
  • by mcfedr
  • Repository
  • 3 Watchers
  • 34 Stars
  • 124,245 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 17 Forks
  • 2 Open issues
  • 78 Versions
  • 5 % Grown

The README.md

Aws Push Bundle

A convenient bundle for registering devices and then pushing to them using amazons SNS service., (*1)

Latest Stable Version License Build Status, (*2)

Install

Composer

php composer.phar require mcfedr/awspushbundle

AppKernel

Include the bundle in your AppKernel, (*3)

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

Config

Put something like this in your config. The arns in the platforms section should be the preconfigured app arns in SNS., (*4)

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 or ec2 role., (*5)

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., (*6)

Usage

Basically have a look at how the ApiController does its stuff, (*7)

  1. Register the device token, (*8)

    $arn = $this->get('mcfedr_aws_push.devices')->registerDevice($token, $platform)
  2. Send message to one device, (*9)

    $this->get('mcfedr_aws_push.messages')->send($message, $arn)
  3. Send message to all devices, (*10)

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

Alternative usage, using topics to send messages to lots of devices, (*11)

  1. Register the device token, (*12)

    $arn = $this->get('mcfedr_aws_push.devices')->registerDevice($token, $platform)
  2. Register the device on the topic, (*13)

    $this->get('mcfedr_aws_push.topics')->registerDeviceOnTopic($arn, $topicArn)
  3. Send messages, (*14)

    $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., (*15)

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., (*16)

If localized text is sent the keys are * message-loc-key * message-loc-args, (*17)

'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., (*18)

Example

Sending:, (*19)

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

ADM received data:, (*20)

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

To handle this data you should detect keys that end with _json and decode the values, (*21)

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

Commands

There are some commands to help manage the devices, (*23)

  1. mcfedr:aws:enable, (*24)

    This will reenable all the devices, (*25)

  2. mcfedr:aws:remove, (*26)

    This will remove any disabled devices. Its a good idea to do something like this regularly to remove old devices, (*27)

  3. mcfedr:aws:subscribe, (*28)

    This will subscribe all devices to a topic, useful when introducing a topic, (*29)

Api Controller

Optional., (*30)

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., (*31)

There are some extra dependencies you must add when using the controller, (*32)

  • 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, (*33)

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

Add the routes in your routing.yaml:, (*34)

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

Usage

The controller provides two urls, both expect a JSON POST body, (*35)

  1. The first is a way to register a device, (*36)

    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., (*37)

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

More info

The Versions

26/01 2018

6.7.0

6.7.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

04/10 2017

6.6.1

6.6.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

14/07 2017

6.6.0

6.6.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

28/05 2017

v5.x-dev

5.9999999.9999999.9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

28/05 2017

5.1.3

5.1.3.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

13/02 2017

6.5.2

6.5.2.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

24/03 2016

6.5.1

6.5.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

02/02 2016

6.5.0

6.5.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

12/01 2016

6.4.0

6.4.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

15/10 2015

6.3.0

6.3.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

30/09 2015

6.2.1

6.2.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

29/09 2015

6.2.0

6.2.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

29/09 2015

6.1.4

6.1.4.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

25/09 2015

6.1.3

6.1.3.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

25/09 2015

6.1.2

6.1.2.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

25/09 2015

6.1.1

6.1.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

25/09 2015

6.1.0

6.1.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

11/09 2015

6.0.2

6.0.2.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

10/09 2015

5.x-dev

5.9999999.9999999.9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

10/09 2015

5.1.2

5.1.2.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

10/09 2015

6.0.1

6.0.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

31/08 2015

6.0.0

6.0.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

28/04 2015

5.1.1

5.1.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

27/04 2015

5.1.0

5.1.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

27/03 2015

5.0.1

5.0.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

27/03 2015

5.0.0

5.0.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

19/03 2015

4.1.1

4.1.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle symfony amazon aws sns notification ios push gcm apns c2dm

02/02 2015

4.1.0

4.1.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle sns notification ios push gcm apns c2dm

26/01 2015

4.0.7

4.0.7.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle sns notification ios push gcm apns c2dm

28/10 2014

4.0.6

4.0.6.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle sns notification ios push gcm apns c2dm

15/10 2014

4.0.5

4.0.5.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Fred Cox

bundle sns notification ios push gcm apns c2dm

14/10 2014

3.0.6

3.0.6.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

14/10 2014

4.0.3

4.0.3.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

14/10 2014

4.0.4

4.0.4.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

10/10 2014

4.0.2

4.0.2.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

10/10 2014

4.0.1

4.0.1.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

07/10 2014

4.0.0

4.0.0.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

07/10 2014

3.0.5

3.0.5.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

17/04 2014

3.0.4

3.0.4.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

05/04 2014

3.0.3

3.0.3.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

05/04 2014

3.0.2

3.0.2.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

05/04 2014

3.0.1

3.0.1.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

03/04 2014

2.4.8

2.4.8.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

21/03 2014

2.4.7

2.4.7.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

16/03 2014

3.0.0

3.0.0.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

06/03 2014

2.4.6

2.4.6.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

03/03 2014

2.4.5

2.4.5.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

25/02 2014

2.4.4

2.4.4.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

18/02 2014

2.4.3

2.4.3.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

16/02 2014

2.4.2

2.4.2.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

14/02 2014

2.4.1

2.4.1.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

14/02 2014

2.4.0

2.4.0.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

11/02 2014

2.3.1

2.3.1.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

11/02 2014

2.3.0

2.3.0.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

11/02 2014

2.2.1

2.2.1.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

07/02 2014

2.2.0

2.2.0.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

01/02 2014

2.1.8

2.1.8.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

01/02 2014

2.1.7

2.1.7.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle sns notification ios push gcm apns c2dm

13/12 2013

2.1.6

2.1.6.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle notification ios push gcm apns c2dm

12/12 2013

2.1.5

2.1.5.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle notification ios push gcm apns c2dm

12/12 2013

2.1.4

2.1.4.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle notification ios push gcm apns c2dm

12/12 2013

2.1.3

2.1.3.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle notification ios push gcm apns c2dm

12/12 2013

2.1.2

2.1.2.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle notification ios push gcm apns c2dm

12/12 2013

2.1.1

2.1.1.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle notification ios push gcm apns c2dm

12/12 2013

2.1.0

2.1.0.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle notification ios push gcm apns c2dm

12/12 2013

2.0.0

2.0.0.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle notification ios push gcm apns c2dm

11/12 2013

1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle notification ios push gcm apns c2dm

11/12 2013

0.0.2

0.0.2.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle notification ios push gcm apns c2dm

11/12 2013

0.0.1

0.0.1.0

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

  Sources   Download

MIT

The Requires

 

by Fred Cox

bundle notification ios push gcm apns c2dm