I am having a couple of issues with secondary tiles with Template 10.
The first is that I can't find the SecondaryTileService in the version that I am using (1.1.12) even though the source is in the GitHub repository and looks old. I have tried searching for a Template 10 Services nuget package but can't find one.
In order to use the secondary tile service I have copied the source code to my application..
The second issue I am having is how to handle the launch from a secondary tile. There doesn't seem to be any documentation on this that I can find.
In a non Template 10 app I can override the OnLaunched method in App.xaml.cs and use the TileId and Arguments properties of the LaunchActivatedEventArgs parameter to handle the navigation to the relevant view.
But the Template 10 BootStrapper seals the OnLaunched method and doesn't provide anything that obviously supplies the launch arguments.
The Template 10 services as seen in GitHub are not included in any Nuget package for reasons unknown.
Handling a launch from a secondary tile is quite an obscure process in Template 10.
First, in the OnStartAsync
method, use the DetermineStartCause
method of the Bootstrapper
to get an AdditionalKinds
enum value. If the value is AdditionalKinds.SecondaryTile
then the app was launched from a secondary tile. You can then cast the IActivatedEventArgs
parameter as a LaunchActivatedEventArgs
, which contains the TileId and launch arguments.
Sample implementation:
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
{
AdditionalKinds cause = DetermineStartCause(args);
if (cause == AdditionalKinds.SecondaryTile)
{
LaunchActivatedEventArgs eventArgs = args as LaunchActivatedEventArgs;
NavigationService.Navigate(typeof (DetailPage), eventArgs.Arguments);
}
else
{
NavigationService.Navigate(typeof (MainPage));
}
return Task.FromResult<object>(null);
}