Download the PHP package clevis/push-notifications without Composer
On this page you can find all versions of the php package clevis/push-notifications. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download clevis/push-notifications
More information about clevis/push-notifications
Files in clevis/push-notifications
Package push-notifications
Short Description Push notifications/messages for mobile devices
License MIT
Homepage https://github.com/clevis/PushNotifications
Informations about the package push-notifications
Clevis/PushNotifications
A bundle to allow sending of push notifications to mobile devices. Currently supports Android (C2DM, GCM), Blackberry and iOS devices.
Installation
To use this bundle in your Nette project add the following to your composer.json
:
and enable it in your config:
NOTE: If you are using Windows, you may need to set the Android GCM use_multi_curl
flag to false for GCM messages to be sent correctly.
Usage
A little example of how to push your first message to an iOS device, we'll assume that you've set up the configuration correctly:
use Clevis\PushNotifications\Message\iOSMessage;
use Clevis\PushNotifications\Notifications;
class Service
{
/**
* @var Notifications
*/
protected $sender;
public function __construct(Notifications $sender)
{
$this->sender = $sender;
}
public function sendPushNotificationExample()
{
$message = new iOSMessage();
$message->setMessage('Oh my! A push notification!');
$message->setDeviceIdentifier('test012fasdf482asdfd63f6d7bc6d4293aedd5fb448fe505eb4asdfef8595a7');
$this->sender->send($message);
}
}
The send method will detect the type of message so if you'll pass it an AndroidMessage
it will automatically send it through the C2DM/GCM servers, and likewise for Mac and Blackberry.
Android messages
Since both C2DM and GCM are still available, the AndroidMessage
class has a small flag on it to toggle which service to send it to. Use as follows:
to send as a GCM message rather than C2DM.
iOS Feedback service
The Apple Push Notification service also exposes a Feedback service where you can get information about failed push notifications - see here for further details.
This service is available within the bundle. The following code demonstrates how you can retrieve data from the service:
Here, $uuids
contains an array of Feedback objects, with timestamp, token length and the device UUID all populated.
Apple recommend you poll this service daily.