使用 pushsharp 发送存折更新 [英] sending passbook update with pushsharp

查看:23
本文介绍了使用 pushsharp 发送存折更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试与苹果的推送通知沙盒服务器进行对话.

I'm trying to test talking to apple's push notification sandbox server.

我按照 此链接(启用推送通知、请求证书颁发机构、上传、生成证书、导出 p12)

I made a certificate following this link (enabled push notification, requested certificate authority, uploaded, generated cert, export p12)

我制作了一个示例 C# 控制台应用程序,如下所示

I made a sample C# console application that looks like the following

PushBroker push = new PushBroker();

var appleCert = File.ReadAllBytes(@"devapns.p12");
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;

push.RegisterAppleService(new ApplePushChannelSettings(false,appleCert,"password"));

push.QueueNotification(new AppleNotification()
                           .ForDeviceToken(token)
                            .WithPasskitUpdate());



 push.StopAllServices(waitForQueuesToFinish: true);

当我跑步时我得到

已达到最大发送尝试次数

The maximum number of Send attempts was reached

我目前使用的PushSharp版本是2.2.1.0

The version of PushSharp I'm currently using is 2.2.1.0

还有什么我需要做的吗?我需要在某处启用 SSL 吗?我的证书是否没有正确安装在我的本地机器上.我不确定我哪里出错了.

Is there something else I need to do? Do I need to enable SSL somewhere? Is my certificate not properly installed on my local machine. I'm not sure where I am going wrong.

注意:p12 文件大约 3KB

NOTE: the p12 file is about 3KB

我在本地计算机上安装了开发证书,只是为了在运行此控制台应用程序时进行测试

I installed the development certificate on my local computer just for testing when running this console application

更新:

我设法将通知成功发送到 apns.但是,唯一的问题是通行证不会在用户设备上更新.根据此链接,我的网络服务是在收到来自 APNS 的存折更新通知后,获取一旦被设备调用的有效序列号列表.然而,这永远不会发生.

I managed to get notifications successfully being sent to apns. However, the only problem is that passes do not update on the user device. According to this link, my webservice is to get a list of valid serial numbers once invoked by the device after receiving a passbook update notification from APNS. However, this never happens.

似乎我可以成功地将我的通知发送到 Apple 通知服务,但从那里 apns 无法将其发送到设备.有什么想法吗?

It seems as if I can successfully send my notification to the Apple Notification Service, but from there the apns cannot send it to the device. Any thoughts?

现在我正在签署通行证并使用相同的通行证类型 ID 证书向 APNS 发送通知.

Right now I am signing the pass and sending a notification to APNS using the same pass type ID certificate.

推荐答案

所以我终于能够使用 APNS 更新存折中的pass.这是一个艰巨的过程,我没有考虑到很多不同的事情.请注意以下几点.

So I was finally able to update a pass in passbook using APNS. It was an arduous process and there were many different things I didn't take into account. Here are a couple things to keep in mind.

  1. 确保在签署通行证和使用 pushsharp 时使用相同的 .p12 文件.(我最初使用了与常规推送通知相关的不同 .p12).所以我最初在问题中发布的链接有点误导,您可以按照这些步骤进行常规推送通知.但是对于存折通知,您需要使用与您的通行证类型 ID 关联的 .p12 文件

  1. Be sure you use the same .p12 file when signing the pass and using pushsharp. (I had originally used a different .p12 associated with regular push notifications). So the link I originally posted in the question is a tad bit misleading, you would follow those steps for regular push notifications. But for passbook notifications, you need use the .p12 file associated with your Pass Type ID

在 PushSharp 中,确保禁用生产/沙盒证书检查.存折没有沙箱环境,所以一切都应该指向生产.在这一行中,添加一个额外的 true 参数以禁用检查

In PushSharp, be sure to disable the production/sandbox certificate check. There is no sandbox environment for passbook, so everything should point to production. In this line, add an extra true parameter to disable the check

push.RegisterAppleService(new ApplePushChannelSettings(false,appleCert,"password", true));

确保您在测试时没有使用测试设备.你也不能使用模拟器

Be sure you aren't using a test device when testing. Also you cannot use the simulator

您收到的推送令牌与注册常规推送通知时收到的 DeviceIDToken 不同.推送令牌是存折独有的

The push token you receive is different than the DeviceIDToken you would receive when registering for regular push notifications. The push token is passbook exclusive

确保在您的服务器上安装了正确的证书.例如,我必须安装通行证类型 ID 证书

Ensure the proper certificates are installed on your server. For example I had to install the pass type ID certificate

做一个telnet feedback.push.apple.com 2196,确保你可以访问apns服务器

Do a telnet feedback.push.apple.com 2196 to ensure you can hit the apns server

这篇关于使用 pushsharp 发送存折更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆