1. Go to this page and download the library: Download wrep/notificato library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wrep / notificato example snippets
// This imports the Composer autoloader
ngStarted
{
/**
* This example sends one pushnotification with an alert to Apples production push servers
*/
public function sendOnePushNotification()
{
// First we get a Notificato instance and tell it what certificate to use as default certificate
$notificato = new Notificato('./certificate.pem', 'passphrase-to-use');
// Now we get a fresh messagebuilder from Notificato
// This message will be send to device with pushtoken 'fffff...'
// it will automaticly be associated with the default certificate
// and we will set the red badge on the App icon to 1
$message = $notificato->messageBuilder()
->setDeviceToken('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff')
->setBadge(1)
->build();
// The message is ready, let's send it!
// Be aware that this method is blocking and on failure Notificato will retry if necessary
$messageEnvelope = $notificato->send($message);
// The returned envelope contains usefull information about how many retries where needed and if sending succeeded
echo $messageEnvelope->getFinalStatusDescription();
}
/**
* This example reads all unregistered devices from Apples feedback service
*/
public function readFeedbackService()
{
// First we get the a Notificato instance and tell it what certificate to use as default certificate
$notificato = new Notificato('./certificate.pem', 'passphrase-to-use');
// Now read all "tuples" from the feedback service, be aware that this method is blocking
$tuples = $notificato->receiveFeedback();
// The tuples contain information about what device unregistered and when it did unregister.
// Don't forget to check if the device reregistered after the "invaidated at" date!
foreach ($tuples as $tuple)
{
echo 'Device ' . $tuple->getDeviceToken() . ' invalidated at ' . $tuple->getInvalidatedAt()->format(\DateTime::ISO8601) . PHP_EOL;
}
}
}
$gettingStarted = new GettingStarted();
$gettingStarted->sendOnePushNotification();
$gettingStarted->readFeedbackService();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.