diff --git a/Parse/Internal/Push/Coder/ParsePushEncoder.cs b/Parse/Internal/Push/Coder/ParsePushEncoder.cs index 8db5db18..fa748a87 100644 --- a/Parse/Internal/Push/Coder/ParsePushEncoder.cs +++ b/Parse/Internal/Push/Coder/ParsePushEncoder.cs @@ -36,6 +36,9 @@ public IDictionary Encode(IPushState state) { } else if (state.ExpirationInterval.HasValue) { payload["expiration_interval"] = state.ExpirationInterval.Value.TotalSeconds; } + if (state.PushTime.HasValue) { + payload["push_time"] = state.PushTime.Value.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"); + } return payload; } diff --git a/Parse/Internal/Push/State/IPushState.cs b/Parse/Internal/Push/State/IPushState.cs index f1ca761d..2e565ab0 100644 --- a/Parse/Internal/Push/State/IPushState.cs +++ b/Parse/Internal/Push/State/IPushState.cs @@ -9,6 +9,7 @@ internal interface IPushState { IEnumerable Channels { get; } DateTime? Expiration { get; } TimeSpan? ExpirationInterval { get; } + DateTime? PushTime { get; } IDictionary Data { get; } String Alert { get; } diff --git a/Parse/Internal/Push/State/MutablePushState.cs b/Parse/Internal/Push/State/MutablePushState.cs index 1ca2dde4..ddcec604 100644 --- a/Parse/Internal/Push/State/MutablePushState.cs +++ b/Parse/Internal/Push/State/MutablePushState.cs @@ -10,6 +10,7 @@ internal class MutablePushState : IPushState { public IEnumerable Channels { get; set; } public DateTime? Expiration { get; set; } public TimeSpan? ExpirationInterval { get; set; } + public DateTime? PushTime { get; set; } public IDictionary Data { get; set; } public String Alert { get; set; } @@ -25,6 +26,7 @@ protected virtual MutablePushState MutableClone() { Channels = Channels == null ? null: new List(Channels), Expiration = Expiration, ExpirationInterval = ExpirationInterval, + PushTime = PushTime, Data = Data == null ? null : new Dictionary(Data), Alert = Alert }; @@ -40,6 +42,7 @@ public override bool Equals(object obj) { this.Channels.CollectionsEqual(other.Channels) && Object.Equals(this.Expiration, other.Expiration) && Object.Equals(this.ExpirationInterval, other.ExpirationInterval) && + Object.Equals(this.PushTime, other.PushTime) && this.Data.CollectionsEqual(other.Data) && Object.Equals(this.Alert, other.Alert); } diff --git a/Parse/ParsePush.cs b/Parse/ParsePush.cs index ef5601e8..d6501ea6 100644 --- a/Parse/ParsePush.cs +++ b/Parse/ParsePush.cs @@ -82,6 +82,19 @@ public DateTime? Expiration { } } + public DateTime? PushTime { + get { return state.PushTime; } + set { + MutateState(s => { + DateTime now = DateTime.Now; + if (value < now || value > now.AddDays(14)) { + throw new InvalidOperationException("Cannot set PushTime in the past or more than two weeks later than now"); + } + s.PushTime = value; + }); + } + } + /// /// The time from initial schedul when this push will expire. This should not be used in tandem with Expiration. ///