protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
ToastNotificationLaunchArguments launchArg = null;
if (args.Arguments != null && args.Arguments != String.Empty)
{
launchArg = ToastNotificationLaunchArguments.FromXmlString(args.Arguments);
}
if (args.PreviousExecutionState == ApplicationExecutionState.Running ||
args.PreviousExecutionState == ApplicationExecutionState.Suspended)
{
Resume();
ProcessLaunchArgument(launchArg);
return;
}
await AvatarLink.ExpandAvatarsToLocal();
Container.RegisterInstance(CoreApplication.MainView.CoreWindow.Dispatcher);
Container
.RegisterType<ISignalingSocketChannel, SignalingSocketChannel>(new ContainerControlledLifetimeManager())
.RegisterType<ISignalingSocketOperation, SignalingSocketOperation>(new ContainerControlledLifetimeManager())
.RegisterType<ISignalingSocketService, SignalingSocketService>(new ContainerControlledLifetimeManager())
.RegisterType<SignalingClient>(new ContainerControlledLifetimeManager())
.RegisterType<IVideoRenderHelper, VideoRenderHelper>()
.RegisterType<IForegroundChannel, ForegroundSignalingUpdateService>(new ContainerControlledLifetimeManager())
.RegisterType<IForegroundUpdateService, ForegroundSignalingUpdateService>(new ContainerControlledLifetimeManager())
.RegisterType<IClientChannel, ClientChannel>(new ContainerControlledLifetimeManager())
.RegisterType<IVoipCoordinator, VoipCoordinator>()
.RegisterType<IHub, Voip.Hub>(new ContainerControlledLifetimeManager())
.RegisterType<VoipContext>(new ContainerControlledLifetimeManager())
.RegisterType<IVoipChannel, VoipChannel>(new ContainerControlledLifetimeManager())
.RegisterType<ISocketConnection, SocketConnection>(new ContainerControlledLifetimeManager())
.RegisterType<NtpService>(new ContainerControlledLifetimeManager())
.RegisterType<IMediaSettingsChannel, MediaSettingsChannel>()
.RegisterType<SettingsViewModel>(new ContainerControlledLifetimeManager())
.RegisterInstance<MainViewModel>(Container.Resolve<MainViewModel>(), new ContainerControlledLifetimeManager());
Container.Resolve<SettingsViewModel>().OnQuitApp -= QuitApp;
Container.Resolve<SettingsViewModel>().OnQuitApp += QuitApp;
var rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored or there are launch arguments
// indicating an alternate launch (e.g.: via toast or secondary tile),
// navigate to the appropriate page, configuring the new page by passing required
// information as a navigation parameter
if (!rootFrame.Navigate(typeof(MainView), Container.Resolve<MainViewModel>()))
{
throw new Exception("Failed to create initial page");
}
}
// Avoid showing two dialogs in a short time or overlapping
// otherwise an Access Denied exception is thrown.
bool _isMessageForLockScreenShowed = false;
var currentStatus = BackgroundExecutionManager.GetAccessStatus();
if (currentStatus == BackgroundAccessStatus.Unspecified ||
currentStatus == BackgroundAccessStatus.Denied)
{
_isMessageForLockScreenShowed = true;
ShowMessageForMissingLockScreen();
}
else
{
await RegisterForPush();
}
Container.Resolve<IMediaSettingsChannel>().RequestAccessForMediaCaptureAsync().AsTask().ContinueWith((d) =>
{
if (!d.Result && !_isMessageForLockScreenShowed)
{
ShowMessageForMissingAccess();
}
});
ProcessLaunchArgument(launchArg);
// Ensure the current window is active
Window.Current.Activate();
}