/// <summary> /// The register task. /// </summary> private static async void PushNotifications() { const string PushNotificationTaskName = "ToastNotifications"; if (GetRegisteredTask(PushNotificationTaskName) != null) { return; } var ns = new NotificationStore(); ns.Register(); await BackgroundExecutionManager.RequestAccessAsync(); await ObtainLockScreenAccess(); var taskBuilder = new BackgroundTaskBuilder { Name = PushNotificationTaskName, TaskEntryPoint = typeof(PushNotificationTask).FullName }; var trigger = new PushNotificationTrigger(); taskBuilder.SetTrigger(trigger); var internetCondition = new SystemCondition(SystemConditionType.InternetAvailable); taskBuilder.AddCondition(internetCondition); try { taskBuilder.Register(); } catch (Exception exception) { } }
/// <summary> /// Initializes static members of the <see cref="Home"/> class. /// </summary> static Home() { var ns = new NotificationStore(); ns.Register(); NotificationStore.PushNotificationReceived += (sender, args) => { if (args.RawNotification == null) { return; } var tasK = new PushNotificationTask(); tasK.Process(args.RawNotification.Content, false); }; }
/// <summary> /// The logout. /// </summary> public void Logout() { Storage.Save("account", null); var ns = new NotificationStore(); ns.UnRegister(); Storage.ClearAll(); }
/// <summary> /// The execute. /// </summary> /// <param name="parameter"> /// The parameter. /// </param> public async override void Execute(object parameter) { this.ExecuteButtonEnabled = false; base.Execute(parameter); if (this.HasErrors) { this.ExecuteButtonEnabled = true; return; } var result = this.accountStore.Authenticate(this.UserName, this.Password); await result.ContinueWith(this.ValidateResponse); if (result.IsFaulted) { this.ExecuteButtonEnabled = true; this.OnPropertyChanged(string.Empty); return; } var ns = new NotificationStore(); ns.Register(); this.navigationService.NavigateRoot<Home>(); }
/// <summary> /// The run. /// </summary> /// <param name="taskInstance"> /// The task instance. /// </param> public void Run(IBackgroundTaskInstance taskInstance) { var store = new NotificationStore(); store.Register(); }
/// <summary> /// The delete. /// </summary> /// <param name="subscriptionId"> /// The subscription id. /// </param> public void Delete(string streamKey) { this.Remove(streamKey); var uri = string.Format("api/subscription?streamKey={0}", streamKey); this.rest.Delete<Subscription>(uri); var ns = new NotificationStore(); ns.Register(); if (SubscriptionsChanged != null) { SubscriptionsChanged(this, null); } }
public void AddSubscription(Subscription subscription) { var subscriptions = this.GetSubsriptions(); if (subscriptions.Any(s => s.Id == subscription.Id)) { if (SubscriptionsChanged != null) { SubscriptionsChanged(this, subscription); } return; } subscriptions.Add(subscription); Storage.Save("subscriptions", subscriptions); var ns = new NotificationStore(); ns.Register(); if (SubscriptionsChanged != null) { SubscriptionsChanged(this, subscription); } }
/// <summary> /// The add. /// </summary> /// <param name="streamKey"> /// The stream id. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public Task<Subscription> Add(string streamKey) { var task = new TaskCompletionSource<Subscription>(); var subs = this.GetSubsriptions(); var subscription = subs.FirstOrDefault(s => s.Stream.Key == streamKey); if (subscription != null) { task.SetResult(subscription); return task.Task; } this.rest.Post<Subscription>("api/subscription/join", new { streamKey }, task.SetResult); var ns = new NotificationStore(); ns.Register(); return task.Task; }