Search code examples
windowscurlapple-push-notificationshttp2

Curl to APNS works on mac, but not on Windows?


Something very strange is happening. On my mac, I can curl to Apple's http2 APNS api, and I get the notification along with the following response:

POST /3/device/{MYTOKEN} HTTP/1.1
Host: api.push.apple.com
User-Agent: curl/7.49.1
Accept: */*
apns-topic: com.domain.myapp
Content-Length: 40
Content-Type: application/x-www-form-urlencoded

Connection state changed (MAX_CONCURRENT_STREAMS updated)!
We are completely uploaded and fine
HTTP 1.0, assume close after body
HTTP/2 200 
apns-id: 9DF86348-7133-8AF2-746D-EC1528769AD8

Closing connection 0
TLSv1.2 (OUT), TLS alert, Client hello (1):

If I do the same on the server I wish to send the notifications from (a Windows Server), I get exactly the same response! - but no notification on the device??

Any idea how this could be?


Solution

  • OK - I solved it!

    The problem was the quote characters in the posted data. The correct format should be:

    curl -d "{\"aps\":{\"alert\":\"test\",\"sound\":\"default\"}}"
    

    I was using single quotes around the outside, which worked on mac, but not on windows. It's still strange that I got the ok message from apple on windows machine, but without any notification.