Ios 来自WebApi应用程序的Apple推送通知

Ios 来自WebApi应用程序的Apple推送通知,ios,asp.net-web-api,apple-push-notifications,pushsharp,Ios,Asp.net Web Api,Apple Push Notifications,Pushsharp,我正在使用Apple推送通知,它在windows 8和windows Server 2008R2上的控制台应用程序和windows服务中工作,但在同一台计算机上传输到WebApi应用程序的相同代码不起作用。我已经通过mmc在Personal和Trusted Root certificate Authority中安装了证书和私钥(私钥可用,已授予IIS_USRS权限)。 代码有点明显,但以防万一: var push = PushBroker(); var appleCert = File.Read

我正在使用Apple推送通知,它在windows 8和windows Server 2008R2上的控制台应用程序和windows服务中工作,但在同一台计算机上传输到WebApi应用程序的相同代码不起作用。我已经通过mmc在Personal和Trusted Root certificate Authority中安装了证书和私钥(私钥可用,已授予IIS_USRS权限)。 代码有点明显,但以防万一:

var push = PushBroker();
var appleCert = File.ReadAllBytes("C:\Users\Documents\Certificates\Push.p12");
push.RegisterAppleService(new PushSharp.Apple.ApplePushChannelSettings(false, appleCert, "pwd"));
PushSharp.Apple.AppleNotification notif = new PushSharp.Apple.AppleNotification()
    .ForDeviceToken("xxx")
    .WithAlert("Updated...")
    .WithBadge(1)
    .WithSound("default");
push.QueueNotification(notif);
//Wait for queue to finish
push.StopAllServices(true);

没有错误/异常等,只是iPhone设备在WebApi应用程序中启动时没有收到通知。

当我出现此错误时,是证书问题。确保使用正确的证书进行生产,因为ApplePushChannelSettings中的第一个参数为false,否则消息将无法传递。还要逐步检查代码,查看是否有任何错误正在生成但未记录。

是否检查了所有事件句柄中的错误?PushBroker实例上有很多错误,您可以在其中订阅以拦截错误(如果有)

订阅:
OnServiceException
OnNotificationFailed


检查IIS | app | users |角色是否具有访问web的所有权限。

看起来像[包含答案。将PushSharp更新到2.2.1后,问题解决了。太好了,好消息!几天后,我将在服务器和客户端上发布一个带有完整PushSharp演示实现的git repo,我将在这里发布,以便您稍后可以查看。