Skip to content

Scheduled push notifications #4105

Closed
Closed
@marvelm

Description

@marvelm

Context

I would like to do the following through the dashboard.

  1. Send push notifications at a specific local date and time.
  2. Send recurring notifications (daily, weekly, monthly).

Implementation

  1. The PushController already supports the push_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 the pushTime 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 and failedPerUTCOffset.

    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}
    }
  2. 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, and dayOfMonth.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions