public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { if (intent.GetBooleanExtra("close", false)) { StopForeground(true); StopSelf(); return(base.OnStartCommand(intent, flags, startId));; } long ticks = intent.GetLongExtra("ticks", 0); Notification notification = new LocalNotificationsManager() .CreateNotificationWithExtraLongData( NotificationsEnum.TimedReminder.Data(), ticks); // Enlist this instance of the service as a foreground service StartForeground((int)NotificationsEnum.TimedReminder, notification); try { _timedReminderCountdownTimer = new TimedReminderCountdownTimer(this, ticks, 1000); _timedReminderCountdownTimer.Start(); } catch (Exception e) { LogUtils.LogException( LogSeverity.WARNING, e, $"{nameof(TimedReminderForegroundService)}-{nameof(StartCommandResult)}: Timer exception"); } return(base.OnStartCommand(intent, flags, startId)); }
/// <summary> /// Connections /// </summary> void Awake() { isLockedForUse = false; rectTransform = GetComponent <RectTransform>(); notificationCanvas = notificationCanvas ?? GetComponent <CanvasGroup>(); manager = Universe.LocalPlayerManager.NotificationsManager; }