0

我在 ASP.NET web api 服务器中使用 push sharp。在我的本地计算机上,一切都像 GCM 和 APNS 的魅力,但一旦上传到天蓝色,只有 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);

            }
        }

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

4

0 回答 0