web-push-php | Web Push library for PHP | Notification library
kandi X-RAY | web-push-php Summary
kandi X-RAY | web-push-php Summary
Web Push library for PHP. WebPush can be used to send notifications to endpoints which server delivers Web Push notifications as described in the Web Push protocol. As it is standardized, you don't have to worry about what server type it relies on.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Prepares the notifications .
- Decrypt a message to deterministic .
- Get VAP ID header .
- Validate the public key .
- Flushes all messages .
- Calculate the agreement key
- Create an instance from an associative array .
- Unserialize a public key .
- Serialize a public key .
- Serialize the subscription .
web-push-php Key Features
web-push-php Examples and Code Snippets
Community Discussions
Trending Discussions on web-push-php
QUESTION
I an creating a PWA app and its working fine, but when I tried to upload on server I stuck on error. On windows local server, everything is fine even notifications, and I dont know much putty/linux commands.
check here my phpinfo file.
I am tring to upload to amazon ec2 server. I installed apache, php, ssl and other required things. And its working file except notifications.
When I call my notification file, I got 503 response. I installed composer, installed everything. I used this github library.
As I understand, I stuck on gmp extension, When I open phpinfo() I didnt see gmp over there. I installed gmp using sudo yum install php-gmp
and also I see a file in php.d named as 20-gmp.ini and it included extension=gmp
. Also restarted apache server using sudo apachectl stop
, sudo apachectl start
.
But still I am getting error. And I coudnt see gmp in phpinfo().
notificationb.php
...ANSWER
Answered 2019-Apr-27 at 09:38I know I am commenting my own question, As I was searching this answer for 3-4 days I think I should share this info with everyone.
The issue is, In linux, PHP have different-different configuration files. The main configuration file is php.ini. And it include other extensions after loading this file and override mail file. These additional configuration are located in /etc/php.d/
(in my case, which is common for mostly).
So just restarting apache server in not enough. We need to also restart php-fpm.
To restart php-fpm: sudo service php-fpm restart
And then restart apache: sudo apachectn restart
You can check more here
QUESTION
I need to implement web notifications for some website and send notifications from php script executed in console.
I found that is possible to implement web notifications without using third-party services, by using this lib https://github.com/web-push-libs/web-push-php Here is good tutorial https://web-push-book.gauntface.com/
But there also are some third-party services that provides sending web notifications, like:
https://onesignal.com/webpush
https://pushalert.co/
https://pushpad.xyz/
and others.
1 - What benefits from using this third party services ?
2 - Is there some limitations when this feature is implemented without using these third-party services ?
3 - How third-party services send notifications, are they using they own push service ?
...ANSWER
Answered 2019-Mar-22 at 13:021 - What benefits from using this third party services ? - you don't have to manage the service. - You Don't have to work on modifications, if there is any update in backends. - You don't have to actually look for cross browser issues. - Easy to implement - You will get Reporting along with this (few gives)
2 - Is there some limitations when this feature is implemented without using these third-party services ? - Limitation will be on membership level, If you choose highest paid membership then there will no limitations attached.
3 - How third-party services send notifications, are they using they own push service ? - They Have their managed backends and for frontends they use the same JS function but well written and optimized.
QUESTION
I am building a web push notification system and I am using the concept used in this example:
https://github.com/Minishlink/web-push-php-example
I have the following code in my JS file. It checks for API support, checks if notifications are not disabled, registers the service worker, asks for permission to display notifications, if allowed subscribes the user and sends the details to the server. If the user is already subscribed, it updates the endpoint value in the DB.
When I run this on Firefox 61, it works fine, but when I run it on Chrome 67 I get this error:
...ANSWER
Answered 2018-Jul-13 at 09:08 if(subscription){
const key = subscription.getKey('p256dh');
const token = subscription.getKey('auth');
const contentEncoding = (PushManager.supportedContentEncodings || ['aesgcm'])[0];
return fetch('/scripts/notification-subscribe.php', {
method: 'POST',
body: JSON.stringify({
endpoint: subscription.endpoint,
publicKey: key ? btoa(String.fromCharCode.apply(null, new Uint8Array(key))) : null,
authToken: token ? btoa(String.fromCharCode.apply(null, new Uint8Array(token))) : null,
contentEncoding,
user: 1,
}),
}).then(() => subscription);
}
}
Just modify this function hope pushSubscription with if block it works
QUESTION
I used the web push library to send push notifications https://github.com/web-push-libs/web-push-php
I getting an internal error while trying to sen push notification
I checked in both PHP version:7.1.22,7.2.9-1
Apache error log throws :
[:error][client ::1:33302] PHP Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /PWA/web-push-php-example/vendor/minishlink/web-push/src/Subscription.php on line 41, referer: http://localhost/PWA/web-push-php-example/src/
And i also tried in Ngnix / error log :
17:22:36 [error] 20232#20232: *46 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: endpoint in /var/www/html/PWA/web-push-php-example/vendor/minishlink/web-push/src/Subscription.php on line 69 PHP message: PHP Fatal error: Uncaught TypeError: Argument 1 passed to Minishlink\WebPush\Subscription::__construct() must be of the type string, null given, called in /var/www/html/PWA/web-push-php-example/vendor/minishlink/web-push/src/Subscription.php on line 72 and defined in /var/www/html/PWA/web-push-php-example/vendor/minishlink/web-push/src/Subscription.php:39 Stack trace: thrown in /var/www/html/PWA/web-push-php-example/vendor/minishlink/web-push/src/Subscription.php on line 39" while reading response header from upstream, client: 127.0.0.1, server: local.pwa.com, request: "POST /PWA/web-push-php-example/src/send_push_notification.php HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "localhost", referrer: "https://localhost/PWA/web-push-php-example/src/"
PHP code :
...ANSWER
Answered 2018-Sep-21 at 11:13Are you absolutely sure you are actually running PHP 7.21 or 7.2? The problem is the question marks in the constructor here:
https://github.com/web-push-libs/web-push-php/blob/master/src/Subscription.php#L41-L43
As you can see from this 3v4l code, it works on all versions over 7.1:
QUESTION
I Want to add Web Notification to my website. I searched on Google and found some tutorials about it. As described in these tutorials I manage to show subscription box to the visitors and I can store their data also.
Main.js
...ANSWER
Answered 2017-Jun-15 at 20:01Take a look at https://web-push-book.gauntface.com/ for a general introduction to Web Push. The Chapter How Push Works and Subscribing a User should be particularly interesting to you. In summary:
- At the client side you need to create a subscription by calling
pushManager.subscribe
. More info here. - You should send this subscription to your server. For example, make an AJAX request to send the subscription (endpoint, keys.p256dh, keys.auth) to the server. More info here.
- On the server you send a push message using the PHP Web Push library. First, you need to configure this library with your keypair. Then, you need to use the subscription (endpoint, keys.p256dh, keys.auth) to send a push message. More info here.
QUESTION
i would like to send push notification in PHP, but i don't know how to do.
I successfully create the Service Worker.
I took a key from this page https://web-push-codelab.appspot.com/. But i don't understand why do they give a private key ?
Then i test my push notifiaction, and i send some notification from this page. But I would like to send push notification from my PHP request. More, i would this work on all the bowsers possible, this code works just with google chrome. Can we do this with firefox, safari, opéra ?
I already use the librairie web-push-php. (avaible here: https://github.com/web-push-libs/web-push-php) I copy/pase the code from the documentation, and i remplace my key, and messages:`
...ANSWER
Answered 2017-Jun-07 at 20:44I took a key from this page https://web-push-codelab.appspot.com/. But i don't understand why do they give a private key ?
The server is supposed to generate a public/private keypair. The public key is used by the browser to create a subscription. The private key remains on the server and is used to encrypt the push message.
And i would like also target the notifications. I would like to send the notification like "xxx commented to your post" or "xxx liked to your post" or "xxx send to you a friend request"
At some point you have the browser register a subscription by calling pushManager.subscribe
(but this code is missing from your question). This returns a promise that resolves to a subscription. You should associate this subscription to the currently authenticated user. For example, you can use AJAX to send the subscription to your server and store it with the currently authenticated user. Whenever you want to notify this user you can use the subscription that is associated with this user.
You might want to take a look at https://web-push-book.gauntface.com/.
QUESTION
I have integrated a Service Worker for receiving Push Notifications in my TYPO3 Extension.
Now I want so send Messages form backend to the clients web-push-php Library.
But how it is possible to integrate the library and its dependencies to TYPO3?
...ANSWER
Answered 2017-Mar-15 at 09:50If you set up your project with composer you can just require minishlink/web-push
and start using class Minishlink\WebPush\WebPush
.
In case you‘re running in "legacy" mode (i.e. classic install without composer) or want to support both you‘ll need a different approach. IMO best practice is bundling composer requirements in .phar
files - this way you can keep your IDE clean and your VCS footprint small. There‘s a blog post with a detailed description about phar bundling in TYPO3 extensions.
This method works for most composer requirements following PSR-0 or PSR-4 and should be viable in your case as minishlink/web-push
seems to follow PSR-4.
You can even advance this by using scripts you can launch by running composer run
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install web-push-php
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page