PushSharp for APNS适用于本地服务器,但不适用于天蓝色

时间:2014-03-20 16:10:44

标签: azure asp.net-web-api apple-push-notifications pushsharp

我在ASP.NET web api服务器中使用push sharp。在我的本地计算机上,一切都像GCM和APNS的魅力一样,但一旦上传到azure,只有GCM消息有效。 APNS没有工作,没有抛出异常。我在推送代理抛出的每个事件中都有跟踪但没有调用跟踪消息。甚至没有排队的消息......

这是我的初始化代码:

 public PushNotificationManager()
        {
            _pushService = new PushBroker();
            _pushService.OnChannelCreated += OnChannelCreated;
            _pushService.OnChannelDestroyed += OnChannelDestroyed;
            _pushService.OnChannelException += OnChannelException;
            _pushService.OnDeviceSubscriptionChanged += OnDeciveSubscriptionChanged;
            _pushService.OnDeviceSubscriptionExpired += OnDeviceSubscriptionExpired;
            _pushService.OnNotificationFailed += OnNorificationFailed;
            _pushService.OnNotificationRequeue += OnNotificationQueued;
            _pushService.OnNotificationSent += OnNOtificationSend;
            _pushService.OnServiceException += OnServiceException;
            InitAndroidPushService();
            InitApplePushService();
        }

        private void InitApplePushService()
        {
            try
            {

                string appDataPath = HttpContext.Current.Server.MapPath("~/app_data");
                //***** Development Server *****//
                //string file = Path.Combine(appDataPath, "PushSharp.PushCert.Development.p12");
                //var appleCert = File.ReadAllBytes(file);
               // _applePushService = new ApplePushService(new ApplePushChannelSettings(false, appleCert, "XXXXXXX"));
                //***** Production Server *****//
                string file = Path.Combine(appDataPath, "PushSharp.PushCert.Production.p12"); 
                var appleCert = File.ReadAllBytes(file);
                _pushService.RegisterAppleService(new ApplePushChannelSettings(true, appleCert, "XXXXXX"));
                Trace.TraceInformation("ApplePushService initialized succesfully");
            }
            catch (Exception e)
            {
                Trace.TraceError("Error initializing ApplePushService : " + e);
                throw;
            }
        }

        private void InitAndroidPushService()
        {
            try
            {
                _pushService.RegisterGcmService(new GcmPushChannelSettings("XXXXXX", "XXXXXX",
                                                                     "XXXXX"));
                Trace.TraceInformation("GooglePushService initialized succesfully");
            }
            catch (Exception e)
            {
                Trace.TraceError("Error initializing AndroidPushService : " + e);

            }
        }

有没有人遇到过这样的事情?

0 个答案:

没有答案