Example #1
0
 /**
  * JsonSerializable implementation
  * @return array payload json serializable instance
  */
 public function jsonSerialize()
 {
     $result = parent::jsonSerialize();
     if (!is_null($this->getAcme())) {
         $result['acme'] = (string) $this->getAcme();
     }
     return $result;
 }
Example #2
0
use alxmsl\APNS\Notification\BasePayload;
use alxmsl\APNS\Notification\Client;
// Create simple alert item
$SimpleItem = new AlertItem();
$SimpleItem->setBody('просто уведомление');
// Create simple payload
$SimplePayload = new BasePayload();
$SimplePayload->setAlertItem($SimpleItem);
// Look at simple payload
var_dump((string) $SimplePayload);
// Create localized alert item
$LocalizedItem = new AlertItem();
$LocalizedItem->setLocalizedKey('GAME_PLAY_REQUEST_FORMAT')->setLocalizedArgs(array('Jenna', 'Frank'));
// Create localized payload
$LocalizedPayload = new BasePayload();
$LocalizedPayload->setAlertItem($LocalizedItem);
// Look at localized payload
var_dump((string) $LocalizedPayload);
// Create custom action button item
$CustomActionItem = new AlertItem();
$CustomActionItem->setBody('Bob wants to play poker')->setActionLocalizedKey('PLAY');
// Create payload with badge
$BadgePayload = new BasePayload();
$BadgePayload->setAlertItem($CustomActionItem)->setBadgeNumber(5);
// Look at custom action payload
var_dump((string) $BadgePayload);
// Create payload with sound
$SoundPayload = new BasePayload();
$SoundPayload->setAlertItem($SimpleItem)->setBadgeNumber(9)->setSoundFile('bingbong.aiff');
// Look at simple payload with sound
var_dump((string) $SoundPayload);
Example #3
0
<?php

/**
 * This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The F**k You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://www.wtfpl.net/ for more details.
 *
 * APNS notification send example
 * @author alxmsl
 * @date 5/2/13
 */
// Include autoloader
include '../source/Autoloader.php';
use alxmsl\APNS\Notification\AlertItem;
use alxmsl\APNS\Notification\BasePayload;
use alxmsl\APNS\Notification\Client;
// Create APNS notification client
$Client = new Client();
// Set secure certificate filename
$Client->setCertificateFile('certificate.production.pem');
// Create needed alert item
$Item = new AlertItem();
$Item->setBody('test1');
// Create payload
$Payload = new BasePayload();
$Payload->setAlertItem($Item)->setBadgeNumber(1)->setIdentifier(time());
// Send notification to the device
$result = $Client->send('c0RreCtT0kEN', $Payload);
var_dump($result);