Exemplo n.º 1
0
        /// <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)
            {
            }
        }
Exemplo n.º 2
0
        /// <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);
                };
        }
Exemplo n.º 3
0
        /// <summary>
        /// The logout.
        /// </summary>
        public void Logout()
        {
            Storage.Save("account", null);

            var ns = new NotificationStore();
            ns.UnRegister();

            Storage.ClearAll();
        }
Exemplo n.º 4
0
        /// <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();
 }
Exemplo n.º 6
0
        /// <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);
            }
        }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
        /// <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;
        }