I am developing a Silverlight 8.1 app in c#. I want to use some of the old phone APIs inside my background periodic task, so I can't use the new IBackgroundTask RT interface.
I created an old style Background agent with OnInvoke override then registered as before in WMAppManifest.xml: <ExtendedTask Name="BackgroundTask">
<BackgroundServiceAgent Specifier="ScheduledTaskAgent" Name="BackgroundAgent" Source="BackgroundAgent" Type="BackgroundAgent.ScheduledAgent" />
</ExtendedTask>
Where BackgroundAgent is my background agent library and ScheduledAgent is my class.
I have enabled Toast notifications for the app in the Package.appxmanifest. My notification system is WNS (in WMAppManifest).
I am trying to launch the task in the old school way:
BackgroundExecutionManager.RequestAccessAsync();
var periodicTask = ScheduledActionService.Find("BackgroundTask");
if (periodicTask != null)
{
ScheduledActionService.Remove("BackgroundTask");
}
periodicTask = new PeriodicTask("BackgroundTask");
(periodicTask as ScheduledTask).Description = "Hello, world.";
ScheduledActionService.Add(periodicTask);
ScheduledActionService.LaunchForTest("BackgroundTask", TimeSpan.FromSeconds(60));
Inside the OnNavigatedTo method of my MainPage.xaml.cs.
I can see this code run.
However, I never see any code run inside my background agent - it is supposed to send me a toast (I tried both with the ShellToast and the new ToastNotificationManager for xml-based toasts) and make a http call - both of which don't happen.
I watched the Build™ video where they mentioned that background agents should be fully supported in Silverlight 8.1 apps.
I can also confirm that my app appears as 'allowed' inside the battery Saver settings, which indicates that the background agent was registered with the os.
What am I doing wrong?