///////////////////////////////////////////////// /// Loads mail status to be displayed in app. /// If mail is recieved after Snapbox has been /// emptied make nofitication ///////////////////////////////////////////////// private void MailStatus() { string obj = HTTPRequestHandler.CreateGetRequest(SnapboxUri + "newest/").ToString(); var snapboxObject = JsonConvert.DeserializeObject <SnapboxObject>(obj); Device.BeginInvokeOnMainThread(() => { if (snapboxObject.MailReceived == true) { mailStatusLbl.Text = "You got mail"; } if (snapboxObject.MailReceived == false) { _notificationSent = false; mailStatusLbl.Text = "Your snapbox is empty"; } }); if (snapboxObject.MailReceived == true && _notificationSent == false) { // Make nofitication if mail is received _notificationSent = true; var toastclass = new ToastClass(); toastclass.ShowToast(new NotificationOptions() { Title = "You got mail!", Description = "Go to your snapbox to pick your snailmail", IsClickable = true, WindowsOptions = new WindowsOptions() { LogoUri = "icon.png" }, ClearFromHistory = false, AllowTapInNotificationCenter = false, AndroidOptions = new AndroidOptions() { HexColor = "#F99D1C", ForceOpenAppOnNotificationTap = true } }); } }
///////////////////////////////////////////////// /// Loads current battery powerlevel to be /// displayed in app. If powerlevel reach 20% /// or lower make nofitication ///////////////////////////////////////////////// private void BatteryStatus() { string obj = HTTPRequestHandler.CreateGetRequest(SnapboxUri + "newest/").ToString(); var snapboxObject = JsonConvert.DeserializeObject <SnapboxObject>(obj); Device.BeginInvokeOnMainThread(() => { powerlevel.Text = snapboxObject.PowerLevel + "%"; if (int.Parse(snapboxObject.PowerLevel) <= 20 && _powerNotificationSent == false) { _powerNotificationSent = true; // Make nofitication if powerlevel is less than 20% var toastclass = new ToastClass(); toastclass.ShowToast(new NotificationOptions() { Title = "Low battery", Description = "Your snapbox powerlevel has reached 20% or lower!", IsClickable = true, WindowsOptions = new WindowsOptions() { LogoUri = "icon.png" }, ClearFromHistory = false, AllowTapInNotificationCenter = false, AndroidOptions = new AndroidOptions() { HexColor = "#F99D1C", ForceOpenAppOnNotificationTap = true } }); } else if (int.Parse(snapboxObject.PowerLevel) > 20) { _powerNotificationSent = false; } }); }