The purpose of this application is to facilitate the testing of push notifications in your application, in the absence of functional options using the .p8 file and without the need to have access to the console of some triggering service. In this project you use Postman to send the payload. I'm developing an application for macOS too but I haven't finished it yet.
- Open
Package.swift
- Wait for Xcode Fetching SPM dependencies
- Run App
- In your console on Xcode you recieve this info:
[ NOTICE ] Server starting on http://127.0.0.1:8080
Run command vapor run serve
in root project folder
- In your Terminal you recieve this info:
[ NOTICE ] Server starting on http://127.0.0.1:8080
if you recieve this error in console:
[ NOTICE ] Server starting on http://127.0.0.1:8080
[ WARNING ] bind(descriptor:ptr:bytes:): Address already in use (errno: 48)
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: bind(descriptor:ptr:bytes:): Address already in use (errno: 48)
2022-01-25 15:45:20.004457-0300 Run[57078:478764] Swift/ErrorType.swift:200: Fatal error: Error raised at top level: bind(descriptor:ptr:bytes:): Address already in use (errno: 48)
Run in terminal lsof -i :8080
this command shows the processes running on port 8080 see the ones with the name Run and kill the processes
sudo kill 4944
for example
-
Default endpoint:
http://127.0.0.1:8080/push/send
-
The body is raw / json
-
key: path to the private key file (.p8)
-
keyIdentifier: is part of your .p8 file in name - Get a key identifier
-
teamIdentifier: Team ID - Locate your Team ID
-
topic: Bundle ID, App ID - Register an App ID
Example payload:
{
"config": {
"key": "/Users/myuser/AuthKey_XPTO.p8",
"keyIdentifier": "XPTO",
"teamIdentifier": "YXPTWREW99",
"topic": "br.com.myapp"
},
"title": "Push Test Dispatcher",
"subTitle": "Push body description",
"deviceToken": "64ff01ef9af8a40c8bf4499d10489ef9a93a1ccd987933c767d52073df015e31"
}
- If you have problem sending with bad request, try changing the .p8 permission to 664 using
chmod 664 <filename>.p8
I hope it helps