Local Notification Configuration Data Structure

Local Notification Configuration Data Structure

Overview

Local notification purpose is to notify users to sue the mobile app for better learning experience.
Here user will get notification on timely basis, and the notification will be purely locally generated. For this, when the user installs the application and run it for the first time,  based on certain  configurations a notification event will be set on a particular date* and time*, which will be triggered at specified time with some message*.

 

Proposed Design

We're proposing the data structure for configuring the local notification.

 

Solution 1:

A notification will be triggered on every Tuesday at 7:30 PM (19:30) from the next coming Tuesday onwards.

And will be repeated 4 time only, after which there won't be any notification.

[   {      time: "19:30",      day: "Tuesday", repeat: 7      occurrence: 4,      title: "{\"en\":\"Message\"}",      msg: "{\"en\":\"Description for Notification\"}"   } ]

Property

type

Value (Example)

Description

Property

type

Value (Example)

Description

time

string

20:15

time in 24 hours

day

string

"Tuesday"

any day of week ["Moday", "Tuesday"... "Sunday"]

Note: either of day or date

date

int

14

date of the month [1-31]

Note: either of day or date

repeat

int

5

number of days notification to be repeated

occurrence

int

10

number of time to repeat the notification

title

string

 

Tittle for notification

msg

string

 

Description of notification

 

Solution 2:

A)

A notification will be triggered on every month 20th at 7:00 PM (19:00) from the next coming date.

And will be repeated monthly, till the given date in `endRepeat` i.e May 20, 2019 

{   time: "19:00",   date: 20,   repeat: "monthly",   endRepeat: { date: "20/05/2019"   } title: "{\"en\":\"Message\"}", msg: "{\"en\":\"Description for Notification\"}" }

 

B)

A notification will be triggered on every day at an interval of 5 days at 10:00 AM (10:00).

And will be occurring for next 6 weeks, after which notification will stop.

{ time: "10:00", interval: 5, endRepeat: { weeks: 6 } title: "{\"en\":\"Message\"}", msg: "{\"en\":\"Description for Notification\"}" }

Property

type

Value (Example)

Description

Property

type

Value (Example)

Description

time

string

20:15

time in 24 hours

day

string

"Tuesday"

any day of week ["Monday", "Tuesday"... "Sunday"]

Note: either of day or date

date

int

14

date of the month [1-31]

Note: either of day or date

repeat

string

monthly

repeat pattern

 

string

weekly

 

string

yearly

 

string

daily

title

string

 

Tittle for notification

msg

string

 

Description of notification

endRepeat

object

 

object with some properties

For repeat object:

Property

type

Value (Example)

Description

Property

type

Value (Example)

Description

months

int

4

after N number of months should stop notification

Note: if given then day should be a date of a month,

example: 20

weeks

int

5

after N number of weeks should stop notification

Note: if given then day should be in weekday,

example: "Tuesday"

days

int

3

after N number of days should stop notification

Note: if given then day and repeat should not be provided

repeatCount

int

10

should be repeated for N number of times only

 

Pros and Cons

 

Solution

Pros

Cons

Solution

Pros

Cons

1

Simple logic not too many conditions for calculating date.

While setting passing the values we've to calculate the number of occurrences based on when and how long we want to continue the notification.

2

Has just have to pass the values it'll automatically calculate the occurrences and stop if required.

Logic will be complex and have to take care of each every value which needs to be passed.

Using In App Notification Payload

After the discussion, we'll be using the same payload structure as described in In App Notification.

{ "id": 14, // id of the notification will be integer, which will be unique "type": 1, // Notification type will be integer - Their can different notification types, like DOWNTIME, GREETINGS, NON-DISPLAY and OTHERS "data":{ // action data contains all the information related to type of the notification, start, msg, notification title start: '2019/05/20 19:00' // first triggered on specified date, and onwards weekly interval: 'week' translations: { "en": { "title": "Title text", "msg": "Descriptive message" }, "default" : { // any default language, if language translation not available then to be used "title": "Title text", "msg": "Descriptive message" } } } }

Property

type

Value (Example)

Description

Property

type

Value (Example)

Description

id

int

 

id of the notification will be integer, which will be unique

type

enum

 

Notification type will be integer - Their can different notification types, like DOWNTIME, GREETINGS, NON-DISPLAY and OTHERS

data

obj

translations

Object specifying the language, Example en

obj

interval

Interval specifies the time interval difference between 2 notification. Example, for weekly once on a specific weekday

Ex: "interval": "weekday"  should go with 2 format of start

obj

start

Date and time from when the notification will be triggered for the first time.  

  1. Format "2019/05/14 12:00"

  2. "4 19:00" [days 1-7, i.e Monday(1), ... Sunday(7)]

obj

occurrence

Number of times the notification should be triggered, if null then notification will be shown infinite times on the specified date and time or weekday

Translations object contains object with these properties with key specifying language code

Property

type

Value (Example)

Description

Property

type

Value (Example)

Description

en

obj

title

Title of notification, should be string

 

obj

msg

Description of notification, should be string

hi

obj

title

Title of notification, should be string

 

obj

msg

Description of notification, should be string

default

obj

title

Title in any default language

 

obj

msg

Message in any default language