【问题标题】:Curl to APNS works on mac, but not on Windows?Curl to APNS 适用于 Mac,但不适用于 Windows?
【发布时间】:2016-11-07 12:13:11
【问题描述】:

发生了一件非常奇怪的事情。在我的 Mac 上,我可以 curl 到 Apple 的 http2 APNS api,并收到通知以及以下响应:

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):

如果我在希望从(Windows 服务器)发送通知的服务器上执行相同操作,我会得到完全相同的响应! - 但设备上没有通知??

知道这是怎么回事吗?

【问题讨论】:

    标签: windows curl apple-push-notifications http2


    【解决方案1】:

    好的,我解决了!

    问题是发布数据中的引号字符。正确的格式应该是:

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

    我在外部使用单引号,这在 mac 上有效,但在 windows 上无效。奇怪的是我在windows机器上收到了来自苹果的ok消息,但没有任何通知。

    【讨论】:

    • @Desmond - 不完全是。我最后用 php 代码中的反引号从 shell 调用 curl 命令!不理想,但它是一个解决方案,直到有人好心地为 php 生成 windows 二进制文件。我从这里使用了 curl 二进制文件:winampplugins.co.uk/curl
    猜你喜欢
    • 2012-02-08
    • 1970-01-01
    • 1970-01-01
    • 2021-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多