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\"}"
  }
]
PropertytypeValue (Example)Description
timestring20:15time in 24 hours
daystring"Tuesday"

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

Note: either of day or date

dateint14

date of the month [1-31]

Note: either of day or date

repeatint5number of days notification to be repeated
occurrenceint10number of time to repeat the notification
titlestring
Tittle for notification
msgstring
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  

{
  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\"}"
}
PropertytypeValue (Example)Description
timestring20:15time in 24 hours
daystring"Tuesday"

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

Note: either of day or date

dateint14

date of the month [1-31]

Note: either of day or date

repeatstringmonthlyrepeat pattern

stringweekly

stringyearly

stringdaily
titlestring
Tittle for notification
msgstring
Description of notification
endRepeatobject
object with some properties

For repeat object:

PropertytypeValue (Example)Description
monthsint4

after N number of months should stop notification

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

example: 20

weeksint5

after N number of weeks should stop notification

Note: if given then day should be in weekday,

example: "Tuesday"

daysint3

after N number of days should stop notification

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

repeatCountint10

should be repeated for N number of times only


Pros and Cons


SolutionProsCons
1Simple 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.
2Has 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"
		}
	}
}
}
PropertytypeValue (Example)Description
idint
id of the notification will be integer, which will be unique
typeenum
Notification type will be integer - Their can different notification types, like DOWNTIME, GREETINGS, NON-DISPLAY and OTHERS
dataobjtranslationsObject specifying the language, Example en
objinterval

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

objstart

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)]
objoccurrenceNumber 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

PropertytypeValue (Example)Description
enobjtitleTitle of notification, should be string

objmsgDescription of notification, should be string
hiobjtitleTitle of notification, should be string

objmsgDescription of notification, should be string
defaultobjtitleTitle in any default language

objmsgMessage in any default language