Конкретное сообщение заставляет Push Sharp ApplePushService перестать работать

Я реализую push-уведомления с помощью push sharp, и у меня есть 2 типа сообщений, которые я отправляю RecomendationLiked и NewFollower, я могу отправлять сообщения RecomendationLiked столько, сколько хочу, и все работает нормально, но отправка одного сообщения NewFollower просто заставляет службу перестать отвечать с помощью никаких исключений или любого из вызванных событий. Это происходит как в продакшене, так и в среде разработки.

Вот логика создания сервиса:

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, "XXX"));

                _applePushService.OnChannelCreated += OnChannelCreated;
                _applePushService.OnChannelDestroyed += OnChannelDestroyed;
                _applePushService.OnChannelException += OnChannelException;
                _applePushService.OnDeviceSubscriptionChanged += OnDeciveSubscriptionChanged;
                _applePushService.OnDeviceSubscriptionExpired += OnDeviceSubscriptionExpired;
                _applePushService.OnNotificationFailed += OnNorificationFailed;
                _applePushService.OnNotificationRequeue += OnNotificationQueued;
                _applePushService.OnNotificationSent += OnNOtificationSend;
                _applePushService.OnServiceException += OnServiceException;
                Trace.TraceInformation("ApplePushService initialized succesfully");
            }
            catch (Exception e)
            {
                Trace.TraceError("Error initializing ApplePushService : " + e);
                throw;
            }
        }

Рекомендация Создание понравившегося сообщения:

private void SendRecomendationLikedMessageToAppleDevice(User likingUser, Recomendation recomendation)
        {
            var notification = new AppleNotification();
            notification.DeviceToken = recomendation.User.PushNotificationID;               
            notification.Payload.Alert.LocalizedKey = "NewLikeNotification";
            notification.Payload.Alert.LocalizedArgs = new List<object> { likingUser.NickName };
            notification.Payload.Sound = "default";
            notification.Payload.AddCustom("LikingUser", likingUser.NickName);
            notification.Payload.AddCustom("AlertType", "RecomendationLiked");
            notification.Payload.AddCustom("ID", likingUser.ID);
            notification.Payload.AddCustom("ImageUrl", likingUser.ImageUrl);
             _applePushService.QueueNotification(notification);
        }

Создание сообщения NewFollower:

 private void SendNewFollowingUserMessageToAppleDevice(User followingUser, User followedUser)
        {
            var notification = new AppleNotification();
            notification.DeviceToken = followedUser.PushNotificationID;
            notification.Payload.Alert.LocalizedKey = "NewFollowingUserNotification";
            notification.Payload.Alert.LocalizedArgs = new List<object> { followingUser.NickName };
            notification.Payload.Sound = "default";
            notification.Payload.AddCustom("followingUser", followingUser.NickName);
            notification.Payload.AddCustom("AlertType", "NewFollowingUser");
            notification.Payload.AddCustom("ID", followingUser.ID);
            notification.Payload.AddCustom("ImageUrl", followingUser.ImageUrl);
            Trace.TraceInformation("Trying to send notifications: "+ notification);
            _applePushService.QueueNotification(notification);
            //_pushService.QueueNotification(notification);
        }

Первый работает, второй молча убивает push-сервис...

Любые идеи?


person Amit Raz    schedule 20.03.2014    source источник


Ответы (1)


Решил наконец...

Проблема связана с длиной сгенерированной строки json. кажется, что максимум 255 символов. что-то выше, и это молча терпит неудачу ...

остерегаться.

Амит

person Amit Raz    schedule 22.05.2014