You shouldn’t be doing step 2. When you run the Vapor project it will create the tables appropriately. Please use Azure Data Studio to delete all tables that exist in the database and then rerun the vapor server so it creates them for you.
Did you manually insert the token or did you let the iOS app create it for you?
For step 7, did you enter the full path to the .p8 file? The pathname should start with a / character for it to work properly.
You’ve got sendPushes.php pointing at Apple’s development server, not the production server, right?
Your error means that it’s not properly connecting to your vapor server. It really seems like you’ve got something strange going on with your networking at your location, or the Vapor server isn’t configured with the proper IP address.
@gargoyle Oh ok. The way the pdf was written is confusing to me. It looks as if I needed to set up my own sql server that connects to docker db I created and create the table. Nowhere does it say that the vapor project will create it for you.
As far as the token goes I let the iOS app create it.
For step 7 I put the .p8 file in the same folder as the project, but did not put a slash in front of the file name. And yes sendPushes.php is pointing to Apples dev server.
@gargoyle just to confirm I just need to use Docker and vapor for this project along with xcode of course. Docker acts as my virtual server and vapor as my local server.
Docker is basically a virtual server, and it is what is running PostgreSQL for you. Most people don’t have a SQL server installed on their mac and so this is the easiest way to put one there.
Vapor is server side Swift (see our book dedicated to Vapor) and that is what runs your web server for you. It runs on your local machine directly. When the vapor server tries to open a connection to the SQL server, your machine redirects it to the PostgreSQL instance running inside of Docker.
I’ll try to explain all of this better in the next release of the book.
@gargoyle Ok I did all that you asked and everything is working. I am not longer getting any errors, but am still not receiving any notifications when I use sendPushes.php. Not sure what I am missing.
I did notice when I run the vapor server I dont get the second line in this statement. Could this be what is causing the problem?
[ INFO ] Migrating ‘psql’ database (FluentProvider.swift:28)
[ INFO ] Preparing migration ‘Token’ (MigrationContainer.swift:50)
[ INFO ] Migrations complete (FluentProvider.swift:32)
May someone tell me why static let entity = "tokens" is significant? I had the same problem as @clapslock. I’d just like to know why it resolved my problem of not receiving the notification. To me, it doesn’t look like entity is being used anywhere but I’m obviously wrong. Apparently it fixed something @gargoyle
@tunjifw Vapor looks for a static variable called entity. If it finds it, that is what it uses for the name of the table. If it doesn’t find it, then it creates a name based on the name of the class.
@gargoyle I have followed everything in the book and added the Lin e
static let entity = “tokens”
to the PushNotifications vapor project in the Token class. I have looked in the docker container and the table tokens exists:
apns=# \c apns
You are now connected to database “apns” as user “apns”.
apns=# \d
List of relations
Schema | Name | Type | Owner
--------±-------±------±------
public | fluent | table | apns
public | tokens | table | apns
The rested app works and I still get the warning
Toms-MH-Mac:~ tom$ php /Users/tom/Repos/Push_Notifications_by_Tutorials_v1/07-expanding-the-application/starter/sendPushes.php
Warning: openssl_sign(): supplied key param cannot be coerced into a private key in /Users/tom/Repos/Push_Notifications_by_Tutorials_v1/07-expanding-the-application/starter/sendPushes.php on line 42
Warning: openssl_sign(): supplied key param cannot be coerced into a private key in /Users/tom/Repos/Push_Notifications_by_Tutorials_v1/07-expanding-the-application/starter/sendPushes.php on line 42
And no notification is recd. @gargoyle can you help?
@tomtom At the top of your PHP script, can you check the AUTH_KEY_PATH to be sure it’s a full path, starting with /, to the p8 file you downloaded from Apple? Does the AUTH_KEY_ID contain the same value as the downloaded file had?
@gargoyle
Thanks for your help. Now the toke works with the full path to the auth file. The the php script runs but no push and the Xcode console displays 2019-05-27 14:23:53.800165-0400 PushNotifications[7111:1505354] TIC TCP Conn Failed [2:0x282585e00]: 12:8 Err(-65554)