APNS Provider API and Postman
Asked Answered
C

1

9

I'm trying to use Postman to create and test Apple Notifications in my iOS app.

For a reason I don't get, requests I send from Postman to either https://api.development.push.apple.com/3/device/<token-device> or https://api.push.apple.com/3/device/<token-device> fail without getting any HTTP response.

What I've done so far:

1 - created and exported a APNS certificate from my developer.apple.com account (as explained there).

2 - converted this .p12 certificate with a recent version of openssl (1.0.2l) to a .pem cert and key like this:

openssl pkcs12 -in apns.p12 -out apns.crt.pem -clcerts -nokeys
openssl pkcs12 -in apns.p12 -out apns.key.pem -nocerts -nodes

3 - configured Postman (Preferences > certificates) to use these .pem files for both Provider API urls (dev and prod)

4 - setup a POST request to those Provider API endpoint for my device token with a apns-topic header that has my bundle id for value, and a HTTP body like this:

{
    "aps" : {
        "alert" : {
            "title" : "Game Request",
            "body" : "Bob wants to play poker"
        }
    }
}

It fails with "Could not get any response, blablabla".

If I check what happens it the Postman console, I see:

POST https://api.development.push.apple.com/3/device/12340e529f85a145b567736e7fd84c9d7e42a43a3c343ec378c2ff071011e4 06:18:08.236

Error: Parse Error

Client Certificate:

keyPath:"/Users/thomas/wksp_myproj/apns.key.pem"

pemPath:"/Users/thomas/wksp_myproj/apns.crt.pem"

Request Headers:

cache-control:"no-cache"

Postman-Token:"99615df2-b2aa-4a51-8d15-8ce27f4e8ca9"

Content-Type:"application/json"

apns-topic:"myproj.app"

Also, when I test with openssl as explained there:

openssl s_client -connect api.development.push.apple.com:443 -cert apns.pem -debug -showcerts -CAfile GeoTrust_Global_CA.pem

I get a lot of outputs with at the end: HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 0aread from 0x7f9445c215c0 [0x7f9446015c03] (5 bytes => 0 (0x0)) read:errno=0

What's going wrong?

Contortive answered 30/8, 2017 at 16:35 Comment(1)
Not sure if it's why I get this error but it seems that the APS Provider API requires HTTP/2 that is not supported by Postman yet :(...Garbers
C
5

OK, forget about Postman, I've ended up using curl with http2 and an updated version of openssl (1.0.2l) and it's working just fine. For those who would like to see an curl command example, it's here.

Contortive answered 31/8, 2017 at 7:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.