PushSharp - IOS - StopAllServices()挂起,没有错误 [英] PushSharp - ios - StopAllServices() hangs with no errors
问题描述
我想通过PushSharp发送推送通知到IOS设备。对于Android,它的工作原理。对于IOS,调用 StopAllServices()
挂着永远不调用任何异常处理程序。
I am trying to send a push notification to IOS device via PushSharp. For android, it works. For IOS, the call to StopAllServices()
hangs forever, without calling any exception handlers.
难道问题是,我得到了一个质子交换膜证书文件,并pushsharp需要一个.p12文件?
Could the problem be that I was given a .pem certificate file, and pushsharp requires a .p12 file?
在code是如下:
var br = new PushBroker();
br.OnNotificationSent += br_OnNotificationSent;
br.OnNotificationFailed += br_OnNotificationFailed;
br.OnChannelException += br_OnChannelException;
br.OnServiceException += br_OnServiceException;
br.OnDeviceSubscriptionChanged += br_OnDeviceSubscriptionChanged;
br.OnDeviceSubscriptionExpired += br_OnDeviceSubscriptionExpired;
br.OnChannelCreated += br_OnChannelCreated;
br.OnChannelDestroyed += br_OnChannelDestroyed;
var appleCert = Resource1.ck; // this is a pem file, not a p12 file!!! could this be the problem?
var sandbox = true;
br.RegisterAppleService(new ApplePushChannelSettings(!sandbox, appleCert, "223684"));
// password given to me by ios developer
var deviceIds = new string[] { "09eddcb8b89494adf802a0caf97d5daaa789a53f52d8c544dbdcf39f2c0b619a" };
foreach (var did in deviceIds)
{
br.QueueNotification(
new AppleNotification()
.ForDeviceToken(did)//the recipient device id
.WithAlert("test: " + DateTime.Now.ToString())//the message
.WithBadge(1)
.WithSound("sound.caf"));
}
br.StopAllServices(waitForQueuesToFinish: true); // hangs forever, no callbacks are called
我使用PushSharp通过GIT中采取,并汇编由我自己与Visual Studio 2013,截至昨日。
I am using PushSharp taken via Git, and compiled by myself with Visual Studio 2013, as of yesterday.
挂起发生则在对code是在一个控制台应用程序,并在一个asp.net应用程序。
The hang happens both if the code is in a console application and in an asp.net application.
我现在用的沙箱,因为有人告诉我。如果我用的是生产服务器,我得到一个异常告诉我,该证书是沙箱。
I am using the sandbox, because I was told to. If I use the production server, I get an exception telling me that the certificate is for the sandbox.
感谢您的任何提示,冻结的原因。
Thanks for any hint as to the cause of the freeze.
推荐答案
在最后它是一个证书的问题。我给出的质子交换膜不被PushSharp接受。只有当我得到这个指南创建了一个名为.p12
In the end it was a certificate problem. The .pem I was given is not accepted by PushSharp. Only when I was given a .p12 created with this guide
的https://$c$c.google.com/ P / APN的锐利/维基/ HowToCreatePKCS12Certificate
,问题就解决了。
不过,PushSharp应该提出一个例外,而不是挂。
However, PushSharp should have raised an exception instead of hanging.
这篇关于PushSharp - IOS - StopAllServices()挂起,没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!