PHP Class Minishlink\WebPush\WebPush

Afficher le fichier Open project: minishlink/web-push Class Usage Examples

Protected Properties

Свойство Type Description
$auth array
$browser Buzz\Browser

Méthodes publiques

Méthode Description
__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 )

Private Methods

Méthode Description
prepareAndSend ( array $notifications )
sendRequest ( string $url, array $headers, string $content ) : Buzz\Message\MessageInterface | null

Method Details

__construct() public méthode

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() public méthode

Flush notifications. Triggers the requests.
public flush ( ) : array | boolean
Résultat 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 méthode

public getAutomaticPadding ( ) : integer
Résultat integer

getBrowser() public méthode

public getBrowser ( ) : Buzz\Browser
Résultat Buzz\Browser

getDefaultOptions() public méthode

public getDefaultOptions ( ) : array
Résultat array

isAutomaticPadding() public méthode

public isAutomaticPadding ( ) : boolean
Résultat boolean

sendNotification() public méthode

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
Résultat array | boolean Return an array of information if $flush is set to true and the queued requests has failed. Else return true

setAutomaticPadding() public méthode

public setAutomaticPadding ( integer $automaticPadding ) : WebPush
$automaticPadding integer Max padding length
Résultat WebPush

setBrowser() public méthode

public setBrowser ( Buzz\Browser $browser ) : WebPush
$browser Buzz\Browser
Résultat WebPush

setDefaultOptions() public méthode

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

Property Details

$auth protected_oe property

protected array $auth
Résultat array

$browser protected_oe property

protected Browser,Buzz $browser
Résultat Buzz\Browser