protected override void OnActivated(IActivatedEventArgs args) { LogService.Write(); // Spot if we are being activated due to inbound pairing request if (args.Kind == ActivationKind.DevicePairing) { LogService.Write("ActivationKind.DevicePairing"); // Get the arguments, which give information about the device which wants to pair with this app if (args is DevicePairingActivatedEventArgs devicePairingArgs) { var deviceInfo = devicePairingArgs.DeviceInformation; // Automatically switch to Bluetooth Settings page var appService = AppService.FindOrCreate(Window.Current.Dispatcher); if (appService.PageService != null) { appService.PageService.NavigateTo(typeof(SettingsPage), Common.GetLocalizedText("BluetoothPreferences/Text")); } else { Frame rootFrame = EnsureRootFrame(); rootFrame.Navigate(typeof(MainPage)); } // Let subscribers know there's a new inbound request. InboundPairingRequested?.Invoke(this, new InboundPairingEventArgs(deviceInfo)); } } else { Frame rootFrame = EnsureRootFrame(); rootFrame.Navigate(typeof(MainPage)); } }
// IAppServiceProvider public IAppService FindOrCreate(CoreDispatcher dispatcher) => AppService.FindOrCreate(dispatcher);