Created
May 11, 2016 17:04
-
-
Save greencoder/16d1f8d7b0fed5b49cf64312ce2b72cc to your computer and use it in GitHub Desktop.
Curl the APNS http/2 API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: You MUST have curl 7.47+ with http/2 support compiled in | |
curl -v \ | |
-d '{"aps":{"alert":"<message>","badge":42}}' \ | |
-H "apns-topic: <bundle id>" \ | |
-H "apns-priority: 10" \ | |
--http2 \ | |
--cert <certificate file> \ | |
https://api.development.push.apple.com/3/device/<device token> |
I am getting below error for,
curl -v \ -d '{"aps":{"alert":"<message>","badge":42}}' \ -H "apns-topic: <bundle id>" \ -H "apns-priority: 10" \ --http2 \ --cert Certificate.p12 \ https://api.development.push.apple.com/3/device/<device token>
curl: (58) could not load PEM client certificate, LibreSSL error error:09FFF06C:PEM routines:CRYPTO_internal:no start line, (no key found, wrong pass phrase, or wrong file format?)
Any idea?
You're using a .p12 certificate, you need to use a .pem
@hissain, you when you add --cert-type P12
it works, tested with curl 7.64.1
on macOS.
curl -v \
-d '{"aps":{"alert":"<message>","badge":42}}' \
-H "apns-topic: <bundle>" \
-H "apns-priority: 10" \
--http2 \
--cert-type P12 --cert Certificates.p12 \
https://api.development.push.apple.com/3/device/<token>
@bzhoek
Thanks a lot. It worked.
Did anyone able to run feedback service from curl command ?
@hissain, you when you add
--cert-type P12
it works, tested withcurl 7.64.1
on macOS.curl -v \ -d '{"aps":{"alert":"<message>","badge":42}}' \ -H "apns-topic: <bundle>" \ -H "apns-priority: 10" \ --http2 \ --cert-type P12 --cert Certificates.p12 \ https://api.development.push.apple.com/3/device/<token>
Thank you!
For specifying the P12 certificate password:
curl -v \
-d '{"aps":{"alert":"<message>","badge":42}}' \
-H "apns-topic: <bundle>" \
-H "apns-priority: 10" \
--http2 \
--cert-type P12 --cert Certificates.p12:password \
https://api.development.push.apple.com/3/device/<token>
this is token base example
curl -v
-H "apns-topic: com.example.MyApp"
-H "authorization: bearer eyAia2lkIjogIjhZTDNHM1JSWDciIH0.eyAiaXNzIjogIkM4Nk5WOUpYM0QiLCAiaWF0IjogIjE0NTkxNDM1ODA2NTAiIH0.MEYCIQDzqyahmH1rz1s-LFNkylXEa2lZ_aOCX4daxxTZkVEGzwIhALvkClnx5m5eAT6Lxw7LZtEQcH6JENhJTMArwLf3sXwi"
-H "apns-id : eabeae54-14a8-11e5-b60b-1697f925ec7b"
-H "apns-push-type : alert"
-H "apns-expiration : 0"
-H "apns-priority : 10"
--http2 --tlsv1.3 https://api.sandbox.push.apple.com/3/device/00fc13adff785122b4ad28809a3420982341241421348097878e577c991de8f0
-d "{"aps":{"alert":"hello"}}"
@izagood `
this is token base example
curl -v -H "apns-topic: com.example.MyApp" -H "authorization: bearer eyAia2lkIjogIjhZTDNHM1JSWDciIH0.eyAiaXNzIjogIkM4Nk5WOUpYM0QiLCAiaWF0IjogIjE0NTkxNDM1ODA2NTAiIH0.MEYCIQDzqyahmH1rz1s-LFNkylXEa2lZ_aOCX4daxxTZkVEGzwIhALvkClnx5m5eAT6Lxw7LZtEQcH6JENhJTMArwLf3sXwi" -H "apns-id : eabeae54-14a8-11e5-b60b-1697f925ec7b" -H "apns-push-type : alert" -H "apns-expiration : 0" -H "apns-priority : 10" --http2 --tlsv1.3 https://api.sandbox.push.apple.com/3/device/00fc13adff785122b4ad28809a3420982341241421348097878e577c991de8f0 -d "{"aps":{"alert":"hello"}}"
how you get authorization token?
can anyone know how can i get an authorization token?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am getting below error for,
Any idea?