Hi
I need local notification to start every day 1 minute after midnight (at 00:01).
The notification is meant to read the data out of database which is relevant for that day.
I managed to schedule a notification for a next day but only once.
I put the Schedule code in Application_start so if application goes to background and is not restarted, but only awakened, notification will not be scheduled for next day.
I tried to use repeatInterval but with no success (or I am using it in a wrong way) - I tried to test it with one minute interval hoping that notification will be raised once more after scheduled time.
Here is the code I use:
Would someone be so kind help me with this since it is important for my app and I am stuck with this and also I am not so experienced with programming...
Thanks
I need local notification to start every day 1 minute after midnight (at 00:01).
The notification is meant to read the data out of database which is relevant for that day.
I managed to schedule a notification for a next day but only once.
I put the Schedule code in Application_start so if application goes to background and is not restarted, but only awakened, notification will not be scheduled for next day.
I tried to use repeatInterval but with no success (or I am using it in a wrong way) - I tried to test it with one minute interval hoping that notification will be raised once more after scheduled time.
Here is the code I use:
B4X:
Private Sub Application_Start (Nav As NavigationController)
...
ScheduleLocalNotification(0,1)
Dim noNot As NativeObject = ln
noNot.SetField("repeatInterval", 64) '16 - daily, 32 - every hour, 64 - every minute
End Sub
Sub ScheduleLocalNotification(Hours As Int, Minutes As Int)
Dim CurrentTime, Today, HourMinTicks As Long
' Dim NextRunTime As Long
DateTime.DateFormat = "d.M.yyyy"
'calculate ticks for hours and minutes schedule
HourMinTicks = Hours * DateTime.TicksPerHour + Minutes * DateTime.TicksPerMinute
'calc ticks up to start of today ... 00:00am
Today = DateTime.DateParse(DateTime.Date(DateTime.Now))
'calc ticks up to current/present time
CurrentTime = DateTime.Now - Today
If HourMinTicks > CurrentTime Then
'Time has Not passed, schedule For Today
NextRunTime = Today + HourMinTicks
Else 'Schedule for tomorrow
NextRunTime = Today + DateTime.TicksPerDay + HourMinTicks 'Schedule for tomorrow
End If
GetDBResult_2 ' reads the Database and sets ln.AlertBody
Dim ln As Notification
ln.Initialize(NextRunTime) 'at scheduled time
ln.IconBadgeNumber = 1
ln.AlertBody = jedan&CRLF&dva
ln.PlaySound = True
ln.Register
End Sub
Would someone be so kind help me with this since it is important for my app and I am stuck with this and also I am not so experienced with programming...
Thanks