How to send local notification daily at random time?


#1

i have tips in my app like this

alltips=[ {“tip”: “1”,
“title”: “title1.”
},{“tip”: “1”,
“title”: “title1.”
},
{“tip”: “1”,
“title”: “title1.”
},
{“tip”: “1”,
“title”: “title1.”
},

];
i have stored these tips locally.i want to send local push notification of these tips.i want to send push notification randomly with random tips.


#2

check out this plugin

Personally i wouldnt show the notifications completly random, consider the times when people are sleeping.


#3

But can we send random tips. I also do not want to send push notifications at random time.


#4
cordova.plugins.notification.local.schedule({
    id: 1,
    title: tip.title
    text: tip.content
    firstAt: monday_9_am,
    every: "week",
    sound: "file://sounds/reminder.mp3",
    icon: "http://icons.com/?cal_id=1",
    data: { meetingId:"123#fg8" }
});
  var tips = [{
    title: 'tip1',
    content: 'tip1'
  }, {
    title: 'tip2',
    content: 'tip2'
  }, {
    title: 'tip3',
    content: 'tip3'
  }]

  var tip = tips[Math.floor(Math.random() * tips.length)];

This could be a way to do what you want. You really just want to generate a random number, based on the length of tips you have in the array.


#5

A post was split to a new topic: Problem with local notification