Using ACR Notifications to fire daily at scheduled times - xamarin

Currently i making a med schedule which fires a local notification everyday at the time your med is due, so far i have got it working for the first day but it will not fire again unless the user clicks on the notification.
else if (Device.RuntimePlatform == Device.iOS)
{
App.BadgeCount = App.BadgeCount + 1;
CrossNotifications.Current.Badge = App.BadgeCount;
Random rnd = new Random();
string stringid = rnd.Next(1, 1000000000).ToString();
stringid = CrossNotifications.Current.Send(usermedid, "Please take " + dosage + " of " + medname, "ding", ms);
Debug.WriteLine("Notification saved" + stringid);
Is there any way to add in my code a way to set the notification to repeat daily at that exact time without having to click on the notification ? Would be best to revert to using UILocalNotifications and using the repeat interval ?
Any help appreciated .. Thanks

From what I can see in the ACR source it can only schedule something through tje calendar, so yes, then you will need a manual action to schedule the next one. Also, I think there is a limit to how many notifications you can schedule in the future.
You are mentioning UILocalNotifications, not that this API is deprecated as of iOS 10. You probably want to use the replacement: UNNotificationRequest. Looking at that API, there is a function to schedule notifications with an interval and the option to let them repeat for each interval. In native code this looks like this:
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: (30*60), repeats: false)
That is probably what you are after. So now you need to either find a plugin that supports this, or write something yourself

Related

Problem with solving the task related to operating on incidents in service now

I am new to service now and have a problem with how to do two tasks.
what is 1. it seems to me that it should be done using business roles, but I don't know what script to use here ... I blocked.
In the second case, I don't know where to start. Can someone help?
As an itil user, I should be able to move an incident to an On Hold state and specify a Date/Time. When this Date/Time is reached, the incident state should change to Update Required. This is so I am reminded that an incident I was working on requires my attention.
As an itil user, I should not be able to select a priority for an incident that is lower priority than any of its children.
If I select a priority for a child incident that is higher than its parent, then I should receive a warning on submit. If I choose to submit anyway, then the parent incident’s priority should be updated to match the child’s.
In my opinion you should consider using SLAs to achieve this requirement. However If you want to achieve It by using BR, you need to hold "the specific date" on Incident table by creating a custom date field. Then you could run the below after BR
var tdy = new GlideDate();
var dt = current.<custom_field_name> ;
if (tdy == dt) {
current.state = 3 // backend value of "On Hold" state
current.update() ;
}
You could use BR again like below on Incident table
var myVar = current.priority ;
var prt = parent.priority ;
if (myVar < prt) {
gs.gs.addErrorMessage("Your message");
current.priority = parent.priority ;
current.update();
}

Script to create same Google Classroom assignment for each day of the school year

Does anyone know of a script that I could adapt to create the same assignment for each school day of a given school year? For example, I would like to create the assignment "Practice your Anki deck. Submit screenshot of your stats" every school day in our class BasicSkills. Ideally, the assignment would be scheduled the week before it was due. This would be a great time saver for those of us elementary school teachers using Google Classroom who have lots of daily and weekly repeating tasks.
I was a programmer many years ago and could adapt an existing script but would struggle to get this working just based on the API description. Thanks.
I think you can, it just depends on how you'll approach it. I'll give you a skeletal structure of the code:
function myFunction() {
Date.prototype.addDays = function(days) {
var dat = new Date(this.valueOf());
dat.setDate(dat.getDate() + days);
return dat;
}
var i;
for (i = 0; i < 3; i++){
var dat = new Date();
Logger.log(dat.addDays(i))
var ClassSource = {
title: "Test File" + dat.addDays(i),
state: "DRAFT",
workType: "ASSIGNMENT"
};
Classroom.Courses.CourseWork.create(ClassSource, 4965804775)
}
//Logger.log(exec);
}
How to approach your goal:
Ideally you want to create the assignment in one go but I don't recommend since there are limitations that you'll encounter (e.g. timeout).
Next, if ever you'll decide to do it in one go, I recommend you to use Utilities.sleep(1000) between calls.
You can also create a list of dates that don't have a class like saturday, sunday, holiday.
Sample result:
Hope this helps.

What is the difference between TYPE_STEP_COUNT_DELTA and AGGREGATE_STEP_COUNT_DELTA data type in Google Fit Android Api?

The Google Fit API describes two of these data types of the Sensor API. However both seem to be returning the same data. Can anyone explain the difference?
TYPE_STEP_COUNT_DELTA:
In the com.google.step_count.delta data type, each data point represents the number of steps taken since the last reading.
AGGREGATE_STEP_COUNT_DELTA:
Aggregate number of steps during a time interval.
You can see more here:
https://developers.google.com/android/reference/com/google/android/gms/fitness/data/DataType
// Setting a start and end date using a range of 1 week before this moment.
Calendar cal = Calendar.getInstance();
Date now = new Date();
cal.setTime(now);
long endTime = cal.getTimeInMillis();
cal.add(Calendar.WEEK_OF_YEAR, -1);
long startTime = cal.getTimeInMillis();
java.text.DateFormat dateFormat = getDateInstance();
Log.i(TAG, "Range Start: " + dateFormat.format(startTime));
Log.i(TAG, "Range End: " + dateFormat.format(endTime));
DataReadRequest readRequest = new DataReadRequest.Builder()
// The data request can specify multiple data types to return, effectively
// combining multiple data queries into one call.
// In this example, it's very unlikely that the request is for several hundred
// datapoints each consisting of a few steps and a timestamp. The more likely
// scenario is wanting to see how many steps were walked per day, for 7 days.
.aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA)
// Analogous to a "Group By" in SQL, defines how data should be aggregated.
// bucketByTime allows for a time span, whereas bucketBySession would allow
// bucketing by "sessions", which would need to be defined in code.
.bucketByTime(1, TimeUnit.DAYS)
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
.build();

Why date validation in Google sheets rejects today's date before 8:00am?

I've created a Google sheet to keep a list of work tasks with a column to track the date on which items are created, and built a script to automatically populate the cells in that column with the day's date when a new line is inserted.
The cell (e.g. G9) that is target of the script uses the following validation formula to make sure that when users change the date, they use a date that is neither a weekend nor in the future:
=and(isdate(G9), weekday(G9,2)<6, G9<=today())
IT ONLY WORKS BUT ONLY IF THE SCRIPT IS RUN ANYTIME AFTER 8:00am ! If I try using it any earlier the cell validation will reject the input!
The script looks like this (curRow is the number of the row that's been added):
// Adds today's date without using =today()
var myrangename = "G"+curRow;
var dateCell = sheet.getRange(myrangename);
var d = new Date();
var dateArr = [];
dateArr[0]=d.getFullYear();
dateArr[1]=d.getMonth() + 1; //Months are zero based
dateArr[2]=d.getDate();
dateCell.setValue(dateArr.join('/'));
(n.b.: I cannot use the script to simply put =today() in the cell because all the entries would change every day. )
WHY DOES IT ONLY WORK AFTER 8:00AM? Is Google somehow running on a different time zone than my computer?? I'm based in the UK, so using BST, but that shouldn't be a problem, shouldn't it...?
Try
var d = new Date();
var d = Utilities.formatDate(d, "GMT+1", "yyyy-MM-dd HH:mm:ss");
I am not sure if google would recognise BST as a time zone, but you could also try
var d = Utilities.formatDate(d, "BST", "yyyy-MM-dd HH:mm:ss");
Thank you for your suggestion, Aprillion. Turns out that a Google Sheets file has its own internal time-zone setting! which in my case was set to American Pacific time (so 8hrs behind)
(You'd think it would pick up the date and time info automatically from Windows, like other applications do!)
To set the sheet's time-zone to the correct one, you need to go to the main menu, click 'File', then 'Spreadsheet settings...', and adjust as necessary.
The script and validation now all work fine.
Thank you all for your help.

ReactiveCocoa limit the update

Possible to somehow limit the update download 0.3 seconds using a ReactiveCocoa?
example:
if (the_previous_update == indefinitely)
{
update;
}
if else (current_time - the_previous_update>=0.3)
{
the_previous_update = current_time;
update;
}
else{
do nothing;
}
Maybe something like this?
RACSignal *updateSignal = ... // a signal that sends a 'next' whenever download has progressed.
[[updateSignal throttle:0.3] subscribeNext:^(id x) {
updateUI();
}];
Yes as #Grav says a throttle seems like the best operation for your use case. A throttle will basically store up next events and dispatch the last one received within your given time interval.
With a throttle you can make sure that you can update your UI every 0.3 seconds and be sure that the value that you use to update will be the last one received in that given time interval.
This differs from delay.

Resources