Exemplo n.º 1
0
        /// <summary>
        /// Called when the user has toggled push notifications on/off. Negotiates with
        /// the MusicPimp servers to register/deregister a push notification URI.
        ///
        /// If enabling succeeds, the enabled value is saved. However, when disabling,
        /// the disabled value is stored regardless of success. We can always kill the
        /// notification channel locally, therefore disabling always succeeds to a sufficient
        /// degree.
        /// </summary>
        /// <param name="toggleValue"></param>
        private async void ToggleChanged(bool toggleValue)
        {
            await WebAware(async() => {
                if (toggleValue)
                {
                    await SubscribeToPush();
                }
                else
                {
                    try {
                        if (Endpoint != null)
                        {
                            await UnsubscribeFromPush(Endpoint);
                        }
                    } finally {
                        Push.Close();
                    }
                }
            });

            LoadingText = DefaultLoadingText;
        }