PHP Класс Minishlink\WebPush\WebPush

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$auth array
$browser Buzz\Browser

Открытые методы

Метод Описание
__construct ( array $auth = [], array $defaultOptions = [], integer | null $timeout = 30, Buzz\Client\AbstractClient $client = null ) WebPush constructor.
flush ( ) : array | boolean Flush notifications. Triggers the requests.
getAutomaticPadding ( ) : integer
getBrowser ( ) : Buzz\Browser
getDefaultOptions ( ) : array
isAutomaticPadding ( ) : boolean
sendNotification ( string $endpoint, string | null $payload = null, string | null $userPublicKey = null, string | null $userAuthToken = null, boolean $flush = false, array $options = [], array $auth = [] ) : array | boolean Send a notification.
setAutomaticPadding ( integer $automaticPadding ) : WebPush
setBrowser ( Buzz\Browser $browser ) : WebPush
setDefaultOptions ( array $defaultOptions )

Приватные методы

Метод Описание
prepareAndSend ( array $notifications )
sendRequest ( string $url, array $headers, string $content ) : Buzz\Message\MessageInterface | null

Описание методов

__construct() публичный Метод

WebPush constructor.
public __construct ( array $auth = [], array $defaultOptions = [], integer | null $timeout = 30, Buzz\Client\AbstractClient $client = null )
$auth array Some servers needs authentication
$defaultOptions array TTL, urgency, topic
$timeout integer | null Timeout of POST request
$client Buzz\Client\AbstractClient

flush() публичный Метод

Flush notifications. Triggers the requests.
public flush ( ) : array | boolean
Результат array | boolean If there are no errors, return true. If there were no notifications in the queue, return false. Else return an array of information for each notification sent (success, statusCode, headers, content)

getAutomaticPadding() публичный Метод

public getAutomaticPadding ( ) : integer
Результат integer

getBrowser() публичный Метод

public getBrowser ( ) : Buzz\Browser
Результат Buzz\Browser

getDefaultOptions() публичный Метод

public getDefaultOptions ( ) : array
Результат array

isAutomaticPadding() публичный Метод

public isAutomaticPadding ( ) : boolean
Результат boolean

sendNotification() публичный Метод

Send a notification.
public sendNotification ( string $endpoint, string | null $payload = null, string | null $userPublicKey = null, string | null $userAuthToken = null, boolean $flush = false, array $options = [], array $auth = [] ) : array | boolean
$endpoint string
$payload string | null If you want to send an array, json_encode it
$userPublicKey string | null
$userAuthToken string | null
$flush boolean If you want to flush directly (usually when you send only one notification)
$options array Array with several options tied to this notification. If not set, will use the default options that you can set in the WebPush object
$auth array Use this auth details instead of what you provided when creating WebPush
Результат array | boolean Return an array of information if $flush is set to true and the queued requests has failed. Else return true

setAutomaticPadding() публичный Метод

public setAutomaticPadding ( integer $automaticPadding ) : WebPush
$automaticPadding integer Max padding length
Результат WebPush

setBrowser() публичный Метод

public setBrowser ( Buzz\Browser $browser ) : WebPush
$browser Buzz\Browser
Результат WebPush

setDefaultOptions() публичный Метод

public setDefaultOptions ( array $defaultOptions )
$defaultOptions array Keys 'TTL' (Time To Live, defaults 4 weeks), 'urgency', and 'topic'

Описание свойств

$auth защищенное свойство

protected array $auth
Результат array

$browser защищенное свойство

protected Browser,Buzz $browser
Результат Buzz\Browser