作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试通过 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/
我正在尝试通过 PushSharp 向 IOS 设备发送推送通知。对于安卓,它有效。对于 IOS,对 StopAllServices() 的调用将永远挂起,而不会调用任何异常处理程序。 问题可能是我获
我正在尝试让 PushSharp(2.0.4.0?)作为 Windows 服务运行。每次服务运行并执行push.QueueNotification() 时,小程序都会挂起对stopAPNS(push)
我是一名优秀的程序员,十分优秀!