When I test the php script I get no notifications on the phone, but get these errors in the Vapor project:
[ ERROR ] invalid HTTP method (/starter/.build/checkouts/vapor.git-4756611856651214512/Sources/Vapor/Logging/Logger+LogError.swift:32)
[ DEBUG ] Conform `HTTPParserError` to `Debuggable` for better debug info. (/starter/.build/checkouts/vapor.git-4756611856651214512/Sources/Vapor/Logging/Logger+LogError.swift:34)
I tried various things to find the cause. The php script goes into the
tokensToReceiveNotification method, but it doesn’t seem to go into the foreach loop at all, which would mean $tokens is empty. Putting a stop in that method returns this:
exception 'PDOException' with message 'could not find driver' in /push_script.php:16
#0 /push_script.php(16): PDO->__construct('pgsql:host=loca...')
Stack entered at 0x104b7da70 in /push_script.php on line 0
I’m not sure where to go from here so any help would be appreciated!
I’m so sorry you’re running into an issue! You’re getting the failure in the PHP script because the vapor service is failing, so don’t worry about the PHP issues right now. I know the Vapor team just did another release, I hope there were no breaking changes! I’ll test this tonight when I get home from work.
What stage are you at in the book? The things I could suggest trying:
- Make sure you’ve fixed all the IP addresses appropriately.
- Try using the final project from the sources to see if maybe there’s an issue with the added code.
- Do an “rm -rf .build” at the toplevel of your project to remove all the Vapor stuff and then “vapor xcode -y” again to force it to redownload everything and rebuild. Note this will take a few minutes to complete.
Actually, looking at your PHP error…I think you’ve got a PHP which isn’t built with PostgreSQL support. You might need to build a new version of PHP that enables PostgreSQL.
@dricard I just ran though chapter 6 and 7 and I was able to successfully send myself a push. I did discover a critical error in one part of the code from chapter 6, so please see this topic:
Unfortunately that’s not the issue you’re seeing.
Actually adding that missing line of code did the trick! I checked and my PHP is current (
PHP 7.1.19 (cli) (built: Aug 17 2018 18:03:17)), and I only got the error in the script if I had breakpoints in there.
Anyhow, I just added your line of code (from the linked thread) above and now I’m receiving the push notifications.
Thanks for looking into this for me, I appreciate. I’m learning a lot, this book is a great resource, thanks!
Awesome! I’m glad things are working for you now, and that you’re finding value in the book!
Hi there guys, @dricard @gargoyle i had thw same issue where i was trying to run the php script, i added that line and all worked perfectly !
wil there be a way to send the push directly from the vapor server ? ( via post request)
Yes, eventually that will be possible. We are waiting for the Vapor team to finalize how the HTTP/2 stuff will be handled with Apple’s servers. Once that’s available, we’ll make an update for the book.
@gargoyle Awosome cant wait (