Urban Airship

Urban Airship PHP Library

This library is a wrapper for the Urban Airship API for PHP.

Urban Airship is no longer actively developing this library but will respond to submitted issues and pull requests. It is provided as sample code, and Urban Airship makes no guarantees as to completeness or regularity of updates. However, we do welcome pull requests with a signed contribution agreement.

Goals

  • Provide a simple interface for the most commonly used APIs
  • Use modern PHP conventions, including using namespaces, abiding by the PHP-FIG Standards, and being autoloadable.

Requirements

  • PHP 5.3 or 5.4.
  • composer
  • httpful
  • monolog

Quick example

require_once 'vendor/autoload.php';

use Urbanairship\Airship;
use UrbanAirship\Push as P;

$response = $airship->push()
    ->setAudience(P\deviceToken("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))
    ->setNotification(P\notification("Hello from php!"))
    ->setDeviceTypes(P\all)
    ->send();

print "Push sent!. Push IDs:" . $response.push_ids;

Logging

The library uses Monolog for request and response logging. At the DEBUG level all requests and responses are logged. At INFO succsesful push requests are logged.

To control the logging, set a handler and a log level.

use UrbanAirship\UALog;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

UALog::setLogHandlers(array(new StreamHandler("php://stdout", Logger::DEBUG)));

To turn off all logging, use a NullHandler

use UrbanAirship\UALog;
use Monolog\Logger;
use Monolog\Handler\NullHandler;

UALog::setLogHandlers(array(new NullHandler()));

Contents:

Apple, StoreKit and iPhone are trademarks of Apple, Inc. Maponics Neighborhood Boundaries © Maponics 2012. DMA® is a registered service mark of The Nielsen Company. Used under License.