Search code examples
apple-push-notificationspasskitapple-wallet

How to get Apple Pass updates to work using the new APNS HTTP2 process?


I'm getting a success response back from Apple, but my Pass never updates. The Pass never even calls my Server to get any updates etc.

This documentation doesn't even mention Apple Passes. https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns/

This seems like the old documentation. https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/PassKit_PG/Updating.html

I created my p8 file (Key) using the method found here. https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-http2-token-authentication

Here are my headers.

request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", GetJwtToken());
request.Headers.TryAddWithoutValidation(":method", "POST");
request.Headers.TryAddWithoutValidation(":path", path);
request.Headers.Add("apns-id", Guid.NewGuid().ToString("D"));
request.Headers.Add("apns-topic", settings.AppBundleIdentifier);
request.Headers.Add("apns-expiration", apnsExpiration.ToString());
request.Headers.Add("apns-priority", apnsPriority.ToString());
request.Headers.Add("apns-push-type", isBackground ? "background" : "alert"); // for iOS 13 required

I'm creating the Passes using the Pass Type Id Certificate. It's a PFX file. The old Pass update method used the PFX file.


Solution

  • I worked on this for a couple of days. I finally found the answer. Instead of using the App Indentifier (com.yourdomain.appname), you have to use the Pass Type ID (pass.com.yourdomain.coupon) as the "apns-topic". Do not include your Team Id in the "apns-topic". The answer is no where in the documentation. I was able to figure things out by reading this post. https://github.com/node-apn/node-apn/issues/469