public void Queue(DtoGcmNotification msg)
 {
     lock (_updateLock)
     {
         if (_androidPushСhannels.ContainsKey(msg.MobileAppId))
         {
             _androidPushСhannels[msg.MobileAppId].IncomingQueue.Enqueue(new GcmNotification()
             {
                 RegistrationIds = new List <string>(msg.Tokens),
                 Data            = JObject.Parse(msg.Payload)
             });
         }
     }
 }
Пример #2
0
        public IHttpActionResult SendPush([FromBody] DtoGcmNotification msg)
        {
            //Remove expired tokens
            var expiredTokens = TokenExperation.CheckExpired(msg.Tokens.ToArray()).ToArray();
            var correctTokens = new List <string>(msg.Tokens);

            foreach (var expiredToken in expiredTokens)
            {
                correctTokens.Remove(expiredToken.Token);
            }
            msg.Tokens = correctTokens.ToArray();

            Service.Queue(msg);
            return(Ok(new DtoPushNotificationResponse()
            {
                Expired = expiredTokens.Select(DtoExpiredToken.FromDataModel)
            }));
        }