public ToMessageDialog ( ) : |
||
return |
/// <summary> /// Displays a dialog and a toast notification corresponding to the given beacon action. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void OnBeaconActionResolvedAsync(object sender, BeaconAction e) { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.Normal, async () => { MessageDialog messageDialog = e.ToMessageDialog(); switch (e.Type) { case BeaconActionType.UrlMessage: case BeaconActionType.VisitWebsite: messageDialog.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async (command) => { await Windows.System.Launcher.LaunchUriAsync(new Uri(e.Url)); _beaconActionDialogOperation.Cancel(); _beaconActionDialogOperation = null; }))); messageDialog.Commands.Add(new UICommand("No")); _beaconActionDialogOperation = messageDialog.ShowAsync(); break; case BeaconActionType.InApp: await messageDialog.ShowAsync(); break; } }); }
/// <summary> /// Handles incoming beacon actions, when the application is running. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void OnBeaconActionResolvedAsync(object sender, BeaconAction e) { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, async () => { string logEntryMessage = "Beacon action resolved:" + "\n- ID: " + e.Id + "\n- " + (string.IsNullOrEmpty(e.Subject) ? "(No subject)" : "Subject: " + e.Subject) + "\n- " + (string.IsNullOrEmpty(e.Body) ? "(No body)" : "Body: " + e.Body) + "\n- " + (string.IsNullOrEmpty(e.Url) ? "(No URL)" : "URL: " + e.Url); AddLogEntry(logEntryMessage); MessageDialog messageDialog = e.ToMessageDialog(); switch (e.Type) { case BeaconActionType.UrlMessage: case BeaconActionType.VisitWebsite: messageDialog.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async (command) => { await Windows.System.Launcher.LaunchUriAsync(new Uri(e.Url)); }))); messageDialog.Commands.Add(new UICommand("No")); break; case BeaconActionType.InApp: break; } await messageDialog.ShowAsync(); }); }