简体   繁体   English

使用APNS HTTP / 2测试开发中的推送通知

[英]Testing push notifications in development with APNS HTTP/2

I am trying to determine what I need to do with respect to the combination of APNS endpoint (eg, development or production), Xcode, and Apple Push certificates in order to test push notifications while in development. 我正在尝试确定针对APNS端点(例如,开发或生产),Xcode和Apple Push证书的组合需要做些什么,以便在开发过程中测试推送通知。 I feel like I've tried every possible combination, but I must be missing something ... 我觉得我已经尝试了所有可能的组合,但是我一定缺少一些东西...

Background 背景

  1. When using Apple's HTTP/2 APNS endpoints from my "dispatch" server, my app/device does not receive pushes, and I receive a BadDeviceToken response from Apple. 从我的“调度”服务器使用Apple的HTTP / 2 APNS端点时,我的应用程序/设备收到推送,并且我从Apple收到BadDeviceToken响应。
  2. Using the exact same .p12 certificate and deviceToken with the Pusher macOS testing app (which uses legacy APNS endpoints), the pushes successfully deliver. Pusher macOS测试应用程序 (使用旧版APNS端点)中使用完全相同的.p12证书和deviceToken ,推送成功交付。

To complicate this further ... 使这一问题更加复杂...

  1. When using Apple's HTTP/2 APNS endpoints from my "dispatch" server for PassKit pushes, my pass/device does receive pushes. 当从我的“分发”服务器使用Apple的HTTP / 2 APNS端点进行PassKit推送时,我的pass /设备确实收到了推送。

So ... 所以...

Point #3 tells me that my "dispatch" server must be configured properly, because pushes to the Apple Wallet pass cause a response (eg, I can see follow-on requests to my server's endpoints from the Wallet / the pass). 第3点告诉我,必须正确配置我的“调度”服务器,因为推送到Apple Wallet通行证会引起响应(例如,我可以看到从Wallet /通行证到服务器端点的后续请求)。

That said, Apple Wallet is a "Production" app. 也就是说,Apple Wallet是“生产”应用程序。 I suspect that, because my app (from Point #1) is non-production/development, something is different. 我怀疑,因为我的应用程序(来自第1点)是非生产/开发的,所以有所不同。

.

Question

Has anyone been able to successfully receive -- in Xcode -- push notifications sent to Apple's api.development.push.apple.com endpoint? 有没有人能够在Xcode中成功接收发送到Apple的api.development.push.apple.com终结点的推送通知? Can you outline the steps you performed (which certificate from developers.apple.com , etc.)? 您能否概述执行的步骤( developers.apple.com等提供的证书)? Thank you! 谢谢!

You should be able to send development push from server: 您应该能够从服务器发送开发推送:

You need to connect to api.development.push.apple.com:443 instead of api.push.apple.com:443. 您需要连接到api.development.push.apple.com:443,而不是api.push.apple.com:443。 You can use production certificate for both. 您都可以使用生产证书。

Sending push to production server can not work with development builds - only with a build that is exported with AppStore configuration, but you can't debug those (at least not with Xcode) 将推送发送到生产服务器不适用于开发版本-仅适用于通过AppStore配置导出的版本,但您无法调试它们(至少不能使用Xcode进行调试)

If you need to check whether the production endpoint works, you can use testflight 如果需要检查生产端点是否正常工作,可以使用testflight

  1. Set development certificate from apple developer portal. 从Apple开发人员门户网站设置开发证书。
  2. Use either production/test server for communicating with APNS. 使用生产/测试服务器之一与APNS进行通信。
  3. Edit your target scheme as follows : 如下编辑目标方案:

在此处输入图片说明

This will ensure that when push notification arrives, control will itself fall in the code. 这将确保当推送通知到达时,控件本身将落入代码中。 It might seem confusing. 这似乎令人困惑。 But here it is how it works : 但这是它的工作方式:
- Install app on device and stop the Run process from Xcode. -在设备上安装应用,然后从Xcode停止运行过程。
- Place a breakpoint on didReceiveRemoteNotification . -在didReceiveRemoteNotification上设置一个断点。
- Send a push notification to device. -向设备发送推送通知。
- Xcode will itself start the app and control will go to the above function. -Xcode本身将启动应用程序,控件将转到上述功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM