Start a new topic

Add a cooldown period between sending push notifications?

Right now I have a onPostSave hook that pushes a message notifying a user's devices that there is new data. However, with my app, users can modify many items at once which will each call save triggering onPostSave and sending a bunch of push notifications within a short time. I'd like to add a minimum amount of time (eg 5~10s) until a user will trigger another push notification in onPostSave. Is there anyway to do that?


Can I modify a queried user inside business logic? That way I can put the current moment.unix() into a user and compare that before sending a push notification. The problem with that is if onPostSave doesn't send a push notification due to it being too close to the last push notification, then I have to wait till the next onPostSave until a push notification is sent and who knows how long that will be. I guess I could kind of solve that by having a scheduled task every 5 mins that checks users for any pending "cancelled" push notifications. 


Ideally, there would be a way to say "wait 10s and if another onPostSave doesn't happen, send the push notification". But I think that would require a longer logic timeout long logic timeout which I cannot afford.


Otherwise I could probably do this internally in my app instead with custom endpoints.


Is there anyway to do this?

1 Comment

Good morning,


This would be a fairly involved process in which you would add a timestamp to the user table, and before sending a push, you would check the timestamp, compare, and if it was more than x since the last push, push again.


You can look at using CollectionAccess ( http://devcenter.kinvey.com/html5/reference/business-logic/reference.html#collection-access-module ) which may make this a little bit easier for you.


Thanks,


Login or Signup to post a comment