简体   繁体   中英

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. 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.
  2. Using the exact same .p12 certificate and deviceToken with the Pusher macOS testing app (which uses legacy APNS endpoints), the pushes successfully deliver.

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.

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

That said, Apple Wallet is a "Production" app. I suspect that, because my app (from Point #1) is non-production/development, something is different.

.

Question

Has anyone been able to successfully receive -- in Xcode -- push notifications sent to Apple's api.development.push.apple.com endpoint? Can you outline the steps you performed (which certificate from developers.apple.com , etc.)? 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. 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)

If you need to check whether the production endpoint works, you can use testflight

  1. Set development certificate from apple developer portal.
  2. Use either production/test server for communicating with 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.
- Place a breakpoint on didReceiveRemoteNotification .
- Send a push notification to device.
- Xcode will itself start the app and control will go to the above function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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