Description
Context
I would like to do the following through the dashboard.
- Send push notifications at a specific local date and time.
- Send recurring notifications (daily, weekly, monthly).
Implementation
-
The
PushController
already supports thepush_time
option and it creates a "scheduled"_PushStatus
.The scheduling logic should remain separate from
parse-server
, and it will be the developer's job to create/pick an implementation. This separate program will search for "scheduled"_PushStatus
objects and send to devices in timezones for which thepushTime
matches the current time. In order to track the delivery/failure rate of notifications, two new fields need to be added to the_PushStatus
:sentPerUTCOffset
andfailedPerUTCOffset
.These new fields are fully backwards compatible and should not affect
parse-server
. The only necessary change is adding a field to the dashboard for the user to specify the send time.
The new schema:_PushStatus: { // ... sentPerUTCOffset: {[key: number]: number}, failedPerUTCOffset: {[key: number]: number} }
-
For this feature, I would like to introduce a new internal class in Parse called
_PushCampaign
. The pusher will create a_PushStatus
object every interval for each_PushCampaign
.
Here's how the schema would look:_PushCampaign: { state: "active" | "inactive", pushStatuses: _PushStatus[], // Pointers interval: "once" | "daily" | "weekly" | "monthly", sendTime: string, // hh:mm:ss dayOfWeek: ?number, // when interval = 'weekly', dayOfMonth: ?number, // when interval = 'monthly' }
When designing this schema, I researched the available standards for representing repeated intervals and I found that ISO 8601 supports it. However, I couldn't find a mature implementation in javascript. If the situation changes in the future, we can easily deprecate
interval
,dayOfWeek
, anddayOfMonth
.
I've been working on a reference implementation of the pusher at @AmpMe/parse-server-scheduled-pusher.
I would appreciate any feedback on this strategy. Thank you for reading.