问题
I'm trying to test talking to apple's push notification sandbox server.
I made a certificate following this link (enabled push notification, requested certificate authority, uploaded, generated cert, export p12)
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);
When I run I get
The maximum number of Send attempts was reached
The version of PushSharp I'm currently using is 2.2.1.0
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.
NOTE: the p12 file is about 3KB
I installed the development certificate on my local computer just for testing when running this console application
UPDATE:
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.
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?
Right now I am signing the pass and sending a notification to APNS using the same pass type ID certificate.
回答1:
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.
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
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 checkpush.RegisterAppleService(new ApplePushChannelSettings(false,appleCert,"password", true));
Be sure you aren't using a test device when testing. Also you cannot use the simulator
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
Ensure the proper certificates are installed on your server. For example I had to install the pass type ID certificate
Do a
telnet feedback.push.apple.com 2196
to ensure you can hit the apns server
来源:https://stackoverflow.com/questions/30381106/sending-passbook-update-with-pushsharp