This is a migrated thread and some comments may be shown as answers.

Delaying cloud function execution & notifications

3 Answers 37 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Arnaud
Top achievements
Rank 1
Arnaud asked on 15 Sep 2016, 03:36 PM

Hello,

I'm here again with another question regarding your backend solution and more specifically, the execution of cloud code and notifications.

In our app, each user is able to vote for items with either a "Like" or a "Dislike". Every time a new vote is made on an item, I want to inform the owner of the item that a vote has been made through a notification. This works great.

However, I want to allow users to make mistake in the sense that if a user unintentionally taps "Dislike" and then reverts his vote right away to "Like", I don't want to send 2 different notifications to the item's owner. The behavior of the Backend should be something like, when a vote is made, wait for a certain duration (lets say 30 seconds) then, send a notification to the item's owner with the current vote.

I know that I can delay notifications (for the chosen duration) but I believe that the payload must be constructed on creation and that it can not be updated afterwards, am I right? Hence, this is not useful because the Backend can not be sure of the state of the vote 30 seconds after creating the payload.

The other option would then be to delay the creation of the notification payload. We handle the notification through a cloud function, so is it possible to plan the execution of a cloud function with a certain delay? Obviously, without interfering with the constrain that the cloud function must be run within a 10 second interval to not be canceled (execution timeout).

 

Thank you very much for your help on this matter and for all the amazing support that you are providing (either here on the forum or by phone call)!

 

Best.

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 19 Sep 2016, 12:07 PM

Hi Arnaud,

I believe scheduling push notifications would be ideal in your case - as you already mentioned you may schedule the notification to be sent on specific time (delayed with 30 sec after the like/dislike is sent) by specifying the NotificationDate in the push notification object fields.

When the push notification is scheduled but not sent yet, it can be modified (the payload can be changed) or the push notification can even be deleted. Thus in the set time window of 30 sec you can modify the push notification or delete it.

To modify its content you can make a PUT request to the following endpoint:

http://api.everlive.com/v1/your-app-id/Push/Notifications/push-notification-id

The push-notification-id would be returned when you create and schedule the push notification in the first place. In the body of the request you would put the modified notification fields. For this request you will need your MasterKey as Authorization header or as you are using Cloud function you can create an Everlive instance with Master Key authorization using Everlive.Sdk.withMasterKey().

To delete the push notification you would make a DELETE request to the same endpoint.

I would suggest to increase the time frame from 30 sec to 1 or 2 min in order to allow more time for the notification to be changed just in case (as the internet connection might be poor for example).

Let me know if this has worked in your case.


Regards,
Martin
Telerik by Progress
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Arnaud
Top achievements
Rank 1
answered on 19 Sep 2016, 01:06 PM

Thank you very much! It is exactly what I was looking for.

I was thinking that the notification could not be changed or deleted after being scheduled. Perfect!

Best

0
Martin
Telerik team
answered on 21 Sep 2016, 11:20 AM
Hi,

I am glad to hear this has worked out.

Regards,
Martin
Telerik by Progress
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
General Discussion
Asked by
Arnaud
Top achievements
Rank 1
Answers by
Martin
Telerik team
Arnaud
Top achievements
Rank 1
Share this question
or