Recommend this page to a friend! |
Download .zip |
Info | Example | View files (54) | Download .zip | Reputation | Support forum (8) | Blog (2) | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
79% | Total: 1,910 This week: 8 | All time: 2,061 This week: 16 |
Version | License | PHP version | Categories | |||
pnserver 1.2.0 | Freely Distributable | 7.4 | Web services, PHP 7 |
Description | Author | |
This package can queue and push notifications to Web users. Recommendations Push notifications for web browsers and now Apple iOS 16.4 pwa Innovation Award |
With this package, web push notifications can be created, encrypted and sent via HTTP request. The subscriptions can be saved and managed. Optionally, the package automatically deletes expired or no longer valid subscriptions. The JavaScript code required on the client side is also included in the package - this has to be slightly adapted to your own project.
> Important: > > The client side of this package works with the Javascript Notification API, which is only available in a secure context (HTTPS). Thus, the complete package also depends on running in a secure context (also in the test environment - unless both the server and the client run on the *'localhost'*). > > Here you can read more about how to set up a secure context in the local development environment.
there are no dependencies to other external libraries!
You can download the Latest release version from PHPClasses.org
required adaptions for your own project (in PNServiceworker.js):
// VAPID appPublic key
const strAppPublicKey = 'create your own VAPID key pair and insert public key here';
// URL to save subscription on server via Fetch API
const strSubscriberURL = 'https://www.your-domain.org/PNSubscriber.php';
// default Notification Title if not pushed by server
const strDefTitle = 'Your company or product';
// default Notification Icon if not pushed by server
const strDefIcon = './elephpant.png';
There are several websites where you can generate your own VAPID key. E.g.:
A tutorial describing the individual steps for using the package is available at PHPclasses.org.
PnTestClient.html shows a simple example Page to subscribe the push notifications.
PNTestServer.php demonstrates, how the Notification Server can be implemented:
rename MyVapid.php.org to MyVapid.php and set your own keys:
$oVapid = new PNVapid(
"mailto:yourmail@yourdomain.de",
"your-generated-public-key",
"your-generated-private-key"
);
This package can use any PSR-3 compliant logger. The logger is initialized with a NullLogger-object by default. The logger of your choice have to be passed to the constructor of the PNDataProvider and set via setLogger() method to the PNServer.
If you are not working with a PSR-3 compatible logger so far, this is a good opportunity to deal with this recommendation and may work with it in the future.
There are several more or less extensive PSR-3 packages available on the Internet.
You can also take a look at the 'XLogger' package and the associated blog 'PSR-3 logging in a PHP application' as an introduction to this topic.
Files |
File | Role | Description | ||
---|---|---|---|---|
Psr (1 directory) | ||||
SKien (2 directories) | ||||
autoloader.php | Aux. | Auxiliary script | ||
elephpant.png | Icon | Icon image | ||
LICENSE | Lic. | License text | ||
MyLogger.php | Example | Example script | ||
MyVapid.php.org | Example | Example script | ||
phpstan.neon | Data | Auxiliary data | ||
phpunit.xml.org | Data | Auxiliary data | ||
PNClient.js | Data | Auxiliary data | ||
PNSendWelcome.php | Example | Example script | ||
PNServiceWorker.js | Data | Auxiliary data | ||
PNSubscriber.php | Example | Example script | ||
PNTestClient.html | Data | Example HTML page client | ||
PNTestPushSingle.php | Example | Example script | ||
PNTestServer.php | Example | Example script | ||
readme.md | Doc. | Documentation |
Files | / | Psr | / | Log |
File | Role | Description |
---|---|---|
AbstractLogger.php | Class | Class source |
InvalidArgumentException.php | Class | Class source |
LoggerAwareInterface.php | Class | Class source |
LoggerAwareTrait.php | Class | Class source |
LoggerInterface.php | Class | Class source |
LoggerTrait.php | Class | Class source |
LogLevel.php | Class | Class source |
NullLogger.php | Class | Class source |
Files | / | SKien | / | PNServer |
File | Role | Description | ||
---|---|---|---|---|
Utils (4 files) | ||||
PNDataProvider.php | Class | Class source | ||
PNDataProviderMySQL.php | Class | Class source | ||
PNDataProviderSQLite.php | Class | Class source | ||
PNEncryption.php | Class | Class source | ||
PNPayload.php | Class | Class source | ||
PNServer.php | Class | Class source | ||
PNServerHelper.php | Class | Class source | ||
PNSubscription.php | Class | Class source | ||
PNVapid.php | Class | Class source |
Files | / | SKien | / | PNServer | / | Utils |
File | Role | Description |
---|---|---|
Curve.php | Class | Class source |
Math.php | Class | Class source |
NistCurve.php | Class | Class source |
Point.php | Class | Class source |
Files | / | SKien | / | Test | / | PNServer |
File | Role | Description | ||
---|---|---|---|---|
testdata (6 files) | ||||
PNDataProviderMySQLTest.php | Class | Class source | ||
PNDataProviderSQLiteTest.php | Class | Class source | ||
PNDataProviderTest.php | Class | Class source | ||
PNEncryptionTest.php | Class | Class source | ||
PNPayloadTest.php | Class | Class source | ||
PNServerTest.php | Class | Class source | ||
PNSubscriptionTest.php | Class | Class source | ||
PNVapidTest.php | Class | Class source | ||
TestHelperTrait.php | Class | Class source | ||
UtilsCurveTest.php | Class | Class source | ||
UtilsMathTest.php | Class | Class source | ||
UtilsPointTest.php | Class | Class source |
Files | / | SKien | / | Test | / | PNServer | / | testdata |
File | Role | Description |
---|---|---|
expired_subscription.json | Data | Auxiliary data |
gone_subscription.json | Data | Auxiliary data |
invalid_subscription.json | Data | Auxiliary data |
inv_endpoint_subscription.json | Data | Auxiliary data |
notfound_subscription.json | Data | Auxiliary data |
valid_subscription.json | Data | Auxiliary data |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Ratings | User Comments (1) | ||||||||||||||||||||||||||||||||||
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.