private void checkEvents() { MyEventEntries myEvents = new MyEventEntries(); PushNotificationsAndroid push = new PushNotificationsAndroid(); myEvents.loadJson(loadMyDatabase()); DateTime currentTime = DateTime.Now; List <EventEntry> temp = new List <EventEntry>(); foreach (EventEntry tempEvent in myEvents.Events) { int timeInterval = 15; int day = tempEvent.StartTime.Day; int month = tempEvent.StartTime.Month; int year = tempEvent.StartTime.Year; if (day == currentTime.Day && month == currentTime.Month && year == currentTime.Year) { int hour = tempEvent.StartTime.Hour; int minute = tempEvent.StartTime.Minute + hour * 60; int minuteNow = currentTime.Minute + currentTime.Hour * 60; if (minute - minuteNow < timeInterval && minute - minuteNow > 0) { temp.Add(tempEvent); } } } if (temp.Count > 1) { string tempString = string.Empty; foreach (EventEntry tempEvent in temp) { tempString += tempEvent.Title + "\n"; } push.SendPush(temp.Count + " Events coming up in the next 15 minutes", tempString, this); } else if (temp.Count == 1) { push.SendPush("Event: " + temp[0].Title + " starting soon", "Starts at " + temp[0].StartTime.ToString("h:mm tt") + "\nLocation: " + temp[0].Location, this); } }
public override void OnMessageReceived(RemoteMessage message) { ISettings AppSettings = CrossSettings.Current; bool adminPushStatus = AppSettings.GetValueOrDefault("pushAdminCheckBox", true); if (adminPushStatus) { PushNotificationsAndroid pa = new PushNotificationsAndroid(); pa.SendPush(message.GetNotification().Title, message.GetNotification().Body, this); } }
public override bool OnStartJob(JobParameters args) { // We don't do any real 'work' in this sample app. All we'll // do is track which jobs have landed on our service, and // update the UI accordingly. PushNotificationsAndroid push = new PushNotificationsAndroid(); jobParamsMap.Add(args); try { checkEvents(); } catch { push.SendPush("Error", "Sorry, there was an issue with the background notification service, please notify the TTC app admin", this); } this.JobFinished(args, false); return(true); }