How to manage Daily Bonus push notification with One Signal? - unity3d

We have a daily bonus system working on date basis. Every date in your local time, you have right to take 1 daily bonus. Ex: If you get daily bonus on 12 July, you will get right to take next bonus on date 13 July without depending on time.
I would like to create push notification for users, but i could not sort it out how to do it?
My previous tries:
1- Whenever player gets daily bonus, i tried to create notification for the next day at 8 pm in her local time.
Problem: If player takes bonus on the next day before 8 pm, i could not delete previously created notification, because there is no delete function for Unity. I also tried collapse_id to deal with it, but collapse_id do not stop sending the notification, just updates notification info with the last one when it is received.
2- I created a tag which is the date when bonus collected, it is something like "2018-07-12". I tried creating a user group who compares these tag with the "today's date"
Problem: there is no such thing like todays date you had to enter it as value, so you can do this by entering console changing date and sending notification and you need to do it everyday.
How can I create such notification system?
Thanks.
Hasan

There are 2 options to do this with OneSignal.
1 - You can cancel the notification if the user already took the bonus.
You can use something like this to make the cancel request:
string url = ""https://onesignal.com/api/v1/notifications/"" + notificationId.ToString() + ""?app_id="" + s_appId;
WebRequest request = WebRequest.Create(url);
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
request.Method = ""DELETE"";
request.GetResponse();
2 - If you are tracking this on your own CRM or database, then you can save the OneSignal PlayerID to the database and target device with the API.
First, get the playerID with the SDK: https://documentation.onesignal.com/docs/unity-sdk#section--getpermissionsubscriptionstate-
Then you can send this data to your CRM or database: https://documentation.onesignal.com/docs/internal-database-crm
​
You can then use include_player_ids on the create notification REST API POST call https://documentation.onesignal.com/reference#section-send-to-specific-devices
If you want to go the tagging option, you should use a timestamp and then target with the API and filters https://documentation.onesignal.com/reference#section-send-to-users-based-on-filters
You should never put your OneSignal REST API key within your app. This needs to be kept private.

Related

Algolia Insight Library - timestamp must not be in the future

Under insights api logs, some events are failed to log with 422 error code and in details it says "timestamp must not be in the future",Insights library is configured like below in Android application
Insights.Configuration configuration =
new Insights.Configuration(5000, 5000, userToken);
Insights insights = Insights.register(GoldenScentApp.getAppContext(), AppConstants.ALGOLIA_APP_ID,
AppConstants.ALGOLIA_KEY, indexName, configuration);
insights.setMinBatchSize(1);
The event was logged with time GMT: Monday, 31 May 2021 06:03:07.048 but the time in Algolia Received at:2021-05-31T06:01:13.859Z
This problem is with algolia sdk. They send old event every time new event send. Like user click event it goes in to local db. Once 10 events limit reach they send event. So in case user send 9 event in one session; then open app after 4 day when another event log algolia will send other events too. But timestamp will be older so they log as error in algolia.
work around : Solution: Set event flushDelay to 5 sec instead of 30 second which in documentation mention as 30 min(idk why).

MongoDB, Mongoose delete element after x time and receive event

I have an expressjs api which uses mongoose to manage the MongoDB. Now I have a document called notifications, some users receive notifications when some conditions are met, e.g. new item(s) are available for the user. The notifications are only sent in x time (stored in user settings) and every user can have max 1 notification in the notification collection. After a notification is sent it is deleted.
I can ofcourse retrieve every x time all user settings of users that have a notification. And then check (time comparison) which users can be notified now.
I would like to delete a notification after x time and then receive a delete event, and then I can send a notification based on that event.
What I did was to create another collection e.g. NotificationTtl. A NotificationTtl is only created when a Notification is created, with the ttl set to the correctly based on the user settings.
We make another collection because it is better not to delete the notification before it has been sent. We can add a field with notificaiton_id, but because every notification has one notificationttl we can give the notificationttl the same id as the notification.
var NotificationTtlSchema = new Schema({ date: { type: Date, index: { unique: true, expires: '1d' }})
var NotificationTtl = mongoose.model('NotificationTtl', NotificationTtlSchema);
NotificationTtl.watch().
on('change', data => {
//this will be called ever time create/update/delete executes here we can listen for delete
});
In the watch we can then listen for a delete operation if the delete operation has been executed we can get the id of the notificationttl and with that id we can retrieve the notification and send it, after it has been send we can delete it.
This all works only if the mongodb is a replicaset and a master node, else the watch functionality wont work.
So what happens now is that everytime the notifiction ttl expires I will get an event in my watch. The event will have operationType called delete, I will then retrieve the correct notification and send it to the user.

sharepoint email workflow not sending mails

i am not able to initiate mails from one of my workflow . i have created one workflow with 2 stages, first one detects the recurrence and second one creates the new task if the first task has been completed.
And another workflow which sent out mails "3" days before start date. This sending mails 3 days before start date is not working, however if i will create the workflow just to sent mails on the start date then that would work fine.
I don't see anything in these steps that would send an email 3 days before the start date. This workflow calculates a reminder date 3 days before the start date, but then the next step only sends the email if the Start Date is before the Reminder Date -- since the Reminder date is always 3 days before Start Date, Start Date will Never be before Reminder Date, thus the email will not be send.
I think you need to add a step before the Send Emails step that says if Reminder Date is greater than Today, then use a Pause until Date to pause until the Reminder Date. Then you can remove the second conditional in the Email step so that all you are checking is the Status before sending the email.

RESVT Bulk Update

I had a question last month about POSTing to Workfront's RESVT field. Since then, I've completed my database to pull all of our department's Leave Calendar data and feed it into Workfront's API as POST methods; however, I've discovered a new problem.
Every time I add a new RESVT event to a user with an existing RESVT event, it deletes the previous event before it saves the new event. I've looked into submitting a bulk edit using the bulk editing format to get all of the events for a user online all at once like this:
https://sosprojects.preview.workfront.com/attask/api/v9.0
/5b6b72b5007d93b00b00dda361398cad?method=put&updates=
[
{
objCode:”RESVT”,
startDate:”2018-08-20T00:00:00:000-0700”,
endDate:”2018-08-23T00:00:00:000-700”
},
{
objCode:”RESVT”,
startDate:”2018-09-20T00:00:00:000-0700”,
endDate:”2018-09-23T00:00:00:000-0700”
}
]
&sessionID=209055d209f94662b32ac50175b34bc7
Which Workfront "accepts" (it doesn't spit out an error code), but it still only saves the last RESVT event (e.g. 9/20 - 9/23).
I've tried using PUT to edit an existing RESVT event, but each RESVT event will only accept one start and one end date so it collapses those attempts into one extra long event.
I know the time-off calendar can manually create multiple RESVT events per user, but I can't figure out how to replicate that feat with my http methods. The calendar always creates new RESVT events for every event logged whenever I add a new event to it; so I think it is doing something like the bulk POST I tried at the top, so why can't my method do the same thing?
The API docs don't show update as a valid method for the RESVT object. Just modify the fields directly for the specific object you want to update. Do you know its ID?
PUT https://<url>.my.workfront.com/attask/api/v9.0/RESVT/<ID of the reserved time you want to edit>?userID=abc1234,startDate=<date>,endDate=<date>

Retrieving Microsoft Live calendar events between 2 dates

I'm currently working on requesting a list of events between 2 dates via Microsoft Live's REST API. I am able to pull back a list of events through the following request URL:
https://apis.live.net/v5.0/me/events
However, this returns a list of events that does not have any specific date frame. For example, I'd want to call a request similar to this:
https://apis.live.net/v5.0/me/events?startDate=2015-02-15&endDate=2015-03-15
I haven't been able to find any useful Microsoft documentation in their disorganized mess of "documentation", so my questions are:
1 - What changes need to be made to the first endpoint above for something like this to work?
2 - What time format does Microsoft use for this kind of request?
Thanks!
I finally found the answer in the middle of a Microsoft documentation page.
Get a limited number of events based on their starting and ending times in Coordinated Universal Time (UTC) format by using the start_time and end_time parameters
To answer my own questions:
#1 - The following endpoint works:
https://apis.live.net/v5.0/me/events?start_time=2015-02-15T00:00:00Z&end_time=2015-03-15T00:00:00Z
#2 - The time format is as follows:
yyyy-MM-dd'T'HH:mm:ss'Z'