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(); }
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; } }