Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Chrome Version 64.0.3282.140 (Official Build) (64-bit) #9

Closed
jmashore opened this issue Feb 8, 2018 · 7 comments
Closed

Comments

@jmashore
Copy link

jmashore commented Feb 8, 2018

First..thank you for taking the time to make this available.
I have installed the project per your instructions and am having a few problems
After navigating to the home directory web-push-php-example and excuting php -S localhost 8000 router.php I am getting the following messages on the console

[Thu Feb 8 10:58:51 2018] PHP Warning: readfile(\C:\ProjectFiles\webpushphp\web-push-php-example\src\app.js): failed to open stream: No such file or directory in C:\ProjectFiles\webpushphp\web-push-php-example\router.php on line 31

If I prefix the reference to app.js to src/app.js in the index file, then Chrome complains about line 1 of app.js with
Uncaught SyntaxError: Unexpected token <

Additional information : I was able to get the index page to successfully load by changing the directory one level down to src and then : php -S localhost 8000
I was then able to navigate to localhost:8000/index.html and it loaded successfully.
It allowed me to subscribe. But when I tried to send a push notification the following php errors were thrown. (I'm using PHP 7.2) -

[Thu Feb  8 11:28:46 2018] ::1:60660 [200]: /push_subscription.php
[Thu Feb  8 11:28:51 2018] PHP Fatal error:  Cannot use FG\ASN1\Object as Object because 'Object' is a special class name in C:\ProjectFiles\webpushphp\web-push-php-example\vendor\mdanter\ecc\src\Serializer\PrivateKey\DerPrivateKeySerializer.php on line 5
[Thu Feb  8 11:28:51 2018] ::1:60666 [200]: /send_push_notification.php - Cannot use FG\ASN1\Object as Object because 'Object' is a special class name in C:\ProjectFiles\webpushphp\web-push-php-example\vendor\mdanter\ecc\src\Serializer\PrivateKey\DerPrivateKeySerializer.php on line 5

I guess I'm back to asking for any help you might give please ?
TIA - Jim

@jmashore
Copy link
Author

jmashore commented Feb 8, 2018

Additional information : So it turns out that mdanter\ecc does not work with PHP 7.2 so I dropped back to php5.6. This cured the Cannot Use Object because of the special name. I'm able to enable push notifications but when I click on send notification nothing happens. No errors are thrown, but nothing is coming up on my browser either. :)

@CitizenDev
Copy link

I had similar issues, followed your fix to change direction and ended up in exactly the same situation where simply nothing happens after sending push notification request. No errors in console or cmd. (PHP 7.0)

@jmashore
Copy link
Author

jmashore commented Feb 9, 2018

I just ended up using this walk through : https://manu.ninja/web-push-notifications
It works. It took me about 30 minutes but, I didn't have to figure out anything. I just followed the steps and it comes with a handy video too.

@CitizenDev
Copy link

So you simply ended up using node.js instead of PHP?

I'm not sure I want to go that road. We run mostly on PHP and would prefer not running node just for those push notifications.

@jmashore
Copy link
Author

No, we are rewriting the pieces in PHP. It still uses the web-push library which has a PHP version. it just gives us a working model so we can see how all the pieces fit together.I'd be happy to share when we get it switched over and working.

@jmashore
Copy link
Author

jmashore commented Feb 12, 2018

Success - I got it to work !
Ok..I think we are making progress here. I actually got this to work.
#1) First be sure you have cacert.pem downloaded from here : https://curl.haxx.se/docs/caextract.html
#2) Then add a line to your php.ini file that looks like this (except use your path):

 ; Location of cacert file for curl ssl
curl.cainfo = "E:\xampp\php\extras\ssl\cacert.pem"

#3) In router.php around line 25 change
include DIRECTORY_SEPARATOR . $filePath;
to
include $filePath;
#4) In router.php around line 30 change
readfile (DIRECTORY_SEPARATOR . $filePath);
to
readfile($filePath);

I'm running this using PHP 5.6.15 in Windows 10
If you have additional issues .. in send_push_notifications.php at the bottom add this line -
errror_log(print_r($res));
It should give you hints as to any other issues you might have.

@Minishlink
Copy link
Owner

Thanks guys for the feedback and investigation! :)

By the way, please don't use this minimalistic and untested router in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants