Scheduled push is crucial to many applications. I know that scheduled push is not currently supported on parse-server, but I am wondering if there is a way to implement it now OR when it might be supported (scheduled push implementation is listed under future improvements).
As with scheduled background jobs, the best way to implement scheduled push notifications on Parse Server is to use a cron job or your favorite scheduling npm.
@hramos I have an application in which users must send other users information which they will be notified about in the future. The time intervals aren't always the same and users can send the information whenever they please. I don't think a scheduling npm is applicable considering that the time intervals are randomized and users can send the information at any time. This task was easily accomplished with push_time in cloud code but that isn't currently supported. Is there any other way around this issue or am I misinformed that a scheduling npm isn't applicable in this situation. (NOTE: I'm not running the server locally either. My parse-server is deployed on mLab.)
You can use kue to define specific scheduled jobs with any time interval you want. This is what I use.
@baymitchell12 mLab only hosts your database. Your Parse Server must be running elsewhere, where you should have at least the option to use kue like @AmbroiseCollon suggested.
@hramos My server is a modified fork of the parse server example deployed through heroku with mLab hosting the database. So kue would be a viable option?
Yes, you can expand the Parse server example project to implement this functionality.
@AmbroiseCollon Can you share me how to implement Kue with Parse-server? I am building a system where it will make auto payment each month to my users (on 28th of each month). I wrote a cloud code method in main.js to send out payment already, but I don't know how to integrate Kue to call that method.
Here is a draft. I don't have time to finish it right now. Do not hesitate to copy paste it and finish it for me or to write suggestions. It should put you on the right path at least. https://medium.com/@ambroisecollon/7754cd31d41e
@AmbroiseCollon Do you have any code available using kue? Can't get to get it to work.
index.js
var kue = require('kue')
var redisUrl = process.env.REDIS_URL
kue.createQueue({ redis: redisUrl })
app.use('/kue', kue.app) // For the kue dashboard
cloud file
var due = require('kue')
var redisUrl = process.env.REDIS_URL
var jobs = kue.createQueue({ redis: redisUrl })
/**
* Create the job for expiring round after 24h
*/
function createRoundExpiredJob(round) {
jobs.create('roundExpired', {
objectId: round.id
})
.removeOnComplete(true)
.delay(round.createdAt.addADay())
.save()
}
queue.js
var kue = require('kue')
var redisUrl = process.env.REDIS_URL
var jobs = kue.createQueue({ redis: redisUrl })
var Parse = require('parse/node')
Parse.initialize('masterKey')
Parse.serverURL = yourServerUrl
/**
* Process the job for ending a round after 24h
*/
jobs.process('roundExpired', function (job, done) {
// Your parse related code and when finished (in save callback for instance):
done()
})
Procfile
web: node index.js
worker: node queue.js
@AmbroiseCollon Thanks a lot!
Most helpful comment
index.js
cloud file
queue.js
Procfile