这是我们用于向苹果发送推送通知以更新Apple Wallet Pass的代码:我们正在使用.net API服务发送推送通知给苹果。
var handler = new HttpClientHandler();
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
handler.ClientCertificates.Add(new X509Certificate2(X509Certificate2.CreateFromEncryptedPemFile("passcertificate.pem", "password", "passkey.pem").Export(X509ContentType.Pfx)));
using (var httpClient = new HttpClient(handler))
{
using (var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.push.apple.com/3/device/pushtoken"))
{
request.Headers.TryAddWithoutValidation("apns-topic", "pass.com.companyname.loyaltycard");
request.Headers.TryAddWithoutValidation("apns-priority", "10");
request.Content = new StringContent("{}");
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/x-www-form-urlencoded");
var response = await httpClient.SendAsync(request);
}
}
上述推送通知调用返回状态200:并且作为响应不返回错误。
但是Apple服务器没有调用我们的Web API来获取更新的序列号:
webServiceURL/version/devices/deviceLibraryIdentifier/registrations/passTypeIdentifier?passesUpdatedSince=date
请帮助我找出可能出错的地方。
1条答案
按热度按时间c0vxltue1#
我已经设法解决了这个问题-我的passTypeIdentifier包含(.),这就是为什么我的web API没有被苹果服务器调用。感谢下面的帖子.. https://stackoverflow.com/a/37080463/3556270