urbanairship/urbanairship

Urban Airship PHP 库

0.4.2 2021-09-28 21:41 UTC

This package is not auto-updated.

Last update: 2024-09-25 11:31:56 UTC


README

用于与 Airship REST API 一起发送通知的 PHP 库。支持 iOS、Android、Amazon 和 Windows。

Airship 已不再积极开发此库,但在通过 https://support.airship.com 提交功能请求、问题或拉取请求时,将予以响应。此库作为示例代码提供,Airship 不对代码的完整性或更新频率作出任何保证。然而,我们欢迎带有已签署的 贡献协议 <https://docs.google.com/forms/d/e/1FAIpQLScErfiz-fXSPpVZ9r8Di2Tr2xDFxt5MgzUel0__9vqUgvko7Q/viewform> 的拉取请求。

要求

PHP >= 5.3

依赖关系

  • Composer
  • Httpful
  • Monolog

开发依赖项

PHPUnit

示例用法

<?php

require_once 'vendor/autoload.php';

use UrbanAirship\Airship;
use UrbanAirship\AirshipException;
use UrbanAirship\UALog;
use UrbanAirship\Push as P;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

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

$airship = new Airship("<app key>", "<master secret>");

try {
    $response = $airship->push()
        ->setAudience(P\iosChannel("Insert your iOS channel here!"))
        ->setNotification(P\notification("Hello from PHP"))
        ->setDeviceTypes(P\deviceTypes("ios"))
        ->send();
} catch (AirshipException $e) {
    print_r($e);
}

资源