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) })); }
public IHttpActionResult SendPush([FromBody] DtoIOSNotification msg) { var expiredToken = TokenExperation.CheckExpired(msg.Token); if (expiredToken != null) { return(Ok(new DtoPushNotificationResponse() { Expired = new[] { DtoExpiredToken.FromDataModel(expiredToken) } })); } Service.Queue(msg); return(Ok(new DtoPushNotificationResponse() { Expired = null })); }
public IHttpActionResult SendPushBatch([FromBody] DtoIOSNotificationBatch msg) { var expiredTokens = TokenExperation.CheckExpired(msg.Tokens).Select(DtoExpiredToken.FromDataModel).ToArray(); var correctTokens = new List <string>(msg.Tokens); foreach (var exToken in expiredTokens) { correctTokens.Remove(exToken.Token); } msg.Tokens = correctTokens.ToArray(); foreach (var notification in msg.ToNotificationList()) { Service.Queue(notification); } return(Ok(new DtoPushNotificationResponse() { Expired = expiredTokens })); }