我有一个WCF服务发送推送通知到IOS设备使用APNS。我在使用PushSharp时使用以下代码。
我在"RegisterAppleService“一步中出错了。错误解释是:"CryptographicException未被用户代码处理--参数不正确。“。
private static PushBroker push;
public string SendNotification()
{
push = new PushBroker();
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;
var appleCert = File.ReadAllBytes("CERT_FILE_NAME.p12");
push.RegisterAppleService(new ApplePushChannelSettings(appleCert, "PASSWORD"));
string devToken = "DEVICE_TOKEN";
push.QueueNotification(new AppleNotification()
.ForDeviceToken(devToken)
.WithAlert("Hello World!")
.WithBadge(7)
.WithSound("sound.caf"));我找不到问题的原因。我该怎么处理这个异常呢?谢谢。
发布于 2014-05-12 20:56:53
我怀疑您只使用了签名请求生成的密钥,而没有使用证书本身。
这里提供了这些步骤,在步骤18中,请确保您正在导出与密钥关联的证书,而不仅仅是密钥本身。
还要确保在开发阶段使用的是开发/沙箱ssl证书。
https://stackoverflow.com/questions/23574823
复制相似问题