Pushsharp不发送通知

时间:2015-09-02 06:33:17

标签: c# ios pushsharp

我正在使用pushsharp开发通知服务。我使用下面的代码向ios设备发送通知。

PushBroker push = new PushBroker();/
                    //Wire up the events for all the services that the broker registers
                    push.OnNotificationSent += NotificationSent;
                    push.OnChannelException += ChannelException;
                    push.OnServiceException += ServiceException;
                    push.OnNotificationFailed += NotificationFailed;
                    push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
                    push.OnChannelCreated += ChannelCreated;
                    push.OnChannelDestroyed += ChannelDestroyed;
                    //make sure your certifcates path are all good 
                    var appleCert = File.ReadAllBytes("D:\\Certificates.p12");
                    push.RegisterAppleService(new ApplePushChannelSettings(true, appleCert, "Estusr@123")); //Extension method
                    push.QueueNotification(new AppleNotification()
                       .ForDeviceToken("118c861fdf169df70a42bcbc9b80c9f2619a30b175862ab22a4395d53ef33298")
                       .WithAlert(DateTime.Now.ToString())//(notification.AlertMessage)
                            //.WithCustomItem("Link", obj)
                       .WithBadge(1)
                       .WithSound("sound.caf"));//sound.caf

                        push.StopAllServices(waitForQueuesToFinish: true); 

我得到了 OnChannelCreated 回调,之后它被卡住了无限时间。我在一个窗口表单应用程序中测试了代码,它按预期工作。

请建议我。

0 个答案:

没有答案