Beispiel #1
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            var deferral = taskInstance.GetDeferral();

            // The user selected this app to be the communication blocking app.
            // Set the list of blocked numbers.
            if (CommunicationBlockingAppManager.IsCurrentAppActiveBlockingApp)
            {
                // If there are no saved blocked numbers, then default to an empty list.
                var blockedNumbers = ApplicationData.Current.LocalSettings.Values["blockedNumbers"] as string[];
                await PhoneCallBlocking.SetCallBlockingListAsync(blockedNumbers ?? new string[] { });
            }
            deferral.Complete();
        }
Beispiel #2
0
        private async Task UpdateBlockListAsync()
        {
            await PhoneCallBlocking.SetCallBlockingListAsync(BlockedNumbers);

            // Save the new blocked numbers list in our private storage.
            var settings = ApplicationData.Current.LocalSettings;

            if (BlockedNumbers.Count > 0)
            {
                settings.Values["blockedNumbers"] = BlockedNumbers.ToArray <string>();
            }
            else
            {
                settings.Values["blockedNumbers"] = null;
            }
        }