Download the PHP package pushpad/pushpad-php without Composer
On this page you can find all versions of the php package pushpad/pushpad-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pushpad/pushpad-php
More information about pushpad/pushpad-php
Files in pushpad/pushpad-php
Package pushpad-php
Short Description Pushpad PHP Library
License MIT
Homepage https://pushpad.xyz
Informations about the package pushpad-php
Pushpad - Web Push Notifications
Pushpad is a service for sending push notifications from websites and web apps. It uses the Push API, which is supported by all major browsers (Chrome, Firefox, Opera, Edge, Safari).
Notifications are delivered in real time even when the users are not on your website and you can target specific users or send bulk notifications.
Installation
Composer
This package requires PHP 8.0+ with the curl extension.
Install the SDK via Composer:
Then include Composer's autoloader:
Manual installation
Clone the repository and require the bootstrap file in your project:
Getting started
First sign up to Pushpad and create a project.
Configure the SDK with your credentials before you make any API calls:
authTokencan be created in the account settings.projectIdis shown in the project settings. If you work with multiple projects you can pass a different project id to individual method calls instead of configuring the global default.
Collecting user subscriptions
Use the JavaScript SDK to subscribe users to push notifications (see the getting started guide).
When you need to sign a uid, generate the HMAC signature with:
Sending push notifications
Use Pushpad\Notification::create() (or the send() alias) to create and send a notification:
- Omit
uidsandtagsto broadcast to everyone. - If you set
uidsand some users are not subscribed to notifications, Pushpad ignores them. - Use boolean expressions inside
tagsfor complex segments (e.g.'zip_code:28865 && !optout:local_events'). - Scheduled notifications require an ISO 8601 timestamp in
send_at(as produced byDateTimeInterface::format(DATE_ATOM)). - You can set default values for most notification fields in the project settings.
- Refer to the REST API docs for more details about the notification fields and their usage.
The response includes useful information:
Getting push notification data
Fetch a single notification and inspect its attributes:
List notifications for a project (pagination supported through the page query parameter):
Pass the project id as the second argument when you prefer not to rely on the globally configured Pushpad\Pushpad::$projectId:
If you need to refresh a previously loaded notification, call $notification->refresh() to hydrate the latest data from the API.
Scheduled notifications
Create a notification that will be sent later:
Cancel a scheduled notification when it is still pending:
Getting subscription count
Retrieve the number of subscriptions associated with a project, optionally filtered by user IDs or tags:
The second argument lets you override the project id if you did not configure Pushpad\Pushpad::$projectId or you need to switch project on the fly.
Getting push subscription data
Fetch subscriptions with optional filters and pagination:
Load a specific subscription when you already know its id:
Updating push subscription data
Although tags and user IDs are usually managed from the JavaScript SDK, you can also update them from server:
Importing push subscriptions
To import existing subscriptions or seed test data use Pushpad\Subscription::create():
Typically subscriptions are collected from the browser using the JavaScript SDK; server-side creation should be reserved for migrations and special workflows.
Deleting push subscriptions
Delete subscriptions programmatically (use with care, the operation is irreversible):
Managing projects
Projects can also be managed via the API for automation use cases:
Managing senders
Senders hold the VAPID credentials used for Web Push:
License
The library is available as open source under the terms of the MIT License.
All versions of pushpad-php with dependencies
ext-curl Version *