infi-nl/push-notifier

This package is abandoned and no longer maintained. No replacement package was suggested.

Send push notifications from PHP to multiple device types

v1.0-beta.1 2015-07-15 09:39 UTC

This package is not auto-updated.

Last update: 2021-04-02 23:08:51 UTC


README

PHP library for sending push notifications to multiple device types.

Apple Push Notification example

Prepare the PushNotifier for sending Apple Push Notifications. Note that you can provide your own Pusher-strategies, to send notifications for Android and Windows Phone for example.

$pushNotifier = new PushNotifier(
  new PusherStrategyCollection(array(
      new ApnPusher(
          'ssl://gateway.sandbox.push.apple.com:2195',
          '<path-to-pem-file>'
      )
  ))
);

Sending an Apple Push Notification

$message              = new ApnMessage();
$message->body        = "<my message>";
$message->badge       = 0;
$message->deviceToken = "<device token>";

$pushNotifier->push($message);

Google Cloud Messaging example

Prepare the PushNotifier for sending Google Cloud Messages.

$pushNotifier = new PushNotifier(
  new PusherStrategyCollection(array(
      new GcmPusher(
        'https://android.googleapis.com/gcm/send',
        '<api-key>'
      )
  ))
);

Sending a Google Cloud Message

$message                  = new GcmMessage();
$message->message         = "<my message>";
$message->title           = "<my title>";
$message->registrationIds = array("<registrationId 1>", "<registrationId 2>", ... , "<registrationId n>");

$pushNotifier->push($message);