2017-08-30 21 views
1

我正尝试使用邮递员在我的iOS应用中创建和测试Apple通知。APNS提供商API和邮差

由于我没有得到的原因,我从Postman发送到https://api.development.push.apple.com/3/device/<token-device>https://api.push.apple.com/3/device/<token-device>的请求失败,未收到任何HTTP响应。

什么我迄今所做的:

1 - 创建,从我的账户developer.apple.com导出的APNS凭证(如解释there)。

2 - 转换此的.p12证书与最近OpenSSL版本(1.0.2l)至为.pem证书和密钥这样的:

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

3 - 配置邮差(首选项>证书)来使用这两个提供商API网址(dev和prod)的.pem文件

4 - 为我的设备令牌设置一个POST请求给我的设备令牌,其中apns-topic标题的值为我的包ID,这个:

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

失败,“无法获得任何回复,blablabla”。

如果我查个究竟吧邮差控制台,我看到:

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"

此外,当我使用OpenSSL测试其解释there

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

我得到了很多的输出与最后: HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 0aread from 0x7f9445c215c0 [0x7f9446015c03] (5 bytes => 0 (0x0)) read:errno=0

怎么回事?

+0

不知道这是为什么我得到这个错误,但似乎APS提供程序API需要Postman不支持的HTTP/2:(... –

回答

0

好吧,忘了邮差,我已经使用curl与http2和openssl(1.0.2l)的更新版本,它工作得很好。对于那些希望看到一个卷曲命令示例的人,这是here