gpt4 book ai didi

c# - PushSharp - ios - StopAllServices() 挂起,没有错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:07:18 25 4
gpt4 key购买 nike

我正在尝试通过 PushSharp 向 IOS 设备发送推送通知。对于安卓,它有效。对于 IOS,对 StopAllServices() 的调用将永远挂起,而不会调用任何异常处理程序。

问题可能是我获得了 .pem 证书文件,而 pushsharp 需要 .p12 文件?

代码如下:

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

截至昨天,我正在使用通过 Git 获取的 PushSharp,并由我自己使用 Visual Studio 2013 编译。

如果代码在控制台应用程序和 asp.net 应用程序中,都会发生挂起。

我正在使用沙箱,因为我被告知要这样做。如果我使用生产服务器,我会收到一个异常,告诉我该证书适用于沙箱。

感谢您提供有关卡住原因的任何提示。

最佳答案

我们花了一整天的时间来猜测问题!最后是Newtonsoft.Json版本不对我们解决方案中的一些项目依赖于该库的旧版本,因此我们运气不好,在 Web 项目的/bin 文件夹中获得了错误的版本。

关于c# - PushSharp - ios - StopAllServices() 挂起,没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24531058/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com