/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { // TODO: Prepare page for display here. // TODO: If your application contains multiple pages, ensure that you are // handling the hardware Back button by registering for the // Windows.Phone.UI.Input.HardwareButtons.BackPressed event. // If you are using the NavigationHelper provided by some templates, // this event is handled for you. await StatusBar.GetForCurrentView().HideAsync(); PushConfig pushConfig = new PushConfig() { UnifiedPushUri = new Uri("https://unifiedpush-edewit.rhcloud.com/ag-push/"), VariantId = "c93fa2a7-70bb-4d34-a308-e0c0a688e6aa", VariantSecret = "fad4c664-1dd3-480a-b966-2a7e9c826af1" }; Registration registration = new WnsRegistration(); registration.PushReceivedEvent += HandleNotification; try { await registration.Register(pushConfig); onRegistrationComplete(); } catch (Exception ex) { new MessageDialog("Error", ex.Message).ShowAsync(); } this.InitializeComponent(); }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { // TODO: Prepare page for display here. // TODO: If your application contains multiple pages, ensure that you are // handling the hardware Back button by registering for the // Windows.Phone.UI.Input.HardwareButtons.BackPressed event. // If you are using the NavigationHelper provided by some templates, // this event is handled for you. await StatusBar.GetForCurrentView().HideAsync(); PushConfig pushConfig = new PushConfig() { UnifiedPushUri = new Uri("<pushServerURL e.g http(s)//host:port/context >"), VariantId = "<variantID e.g. 1234456-234320>", VariantSecret = "<variantSecret e.g. 1234456-234320>" }; Registration registration = new WnsRegistration(); registration.PushReceivedEvent += HandleNotification; try { await registration.Register(pushConfig); var param = e.Parameter as string; if (!string.IsNullOrEmpty(param)) { await registration.SendMetricWhenAppLaunched(pushConfig, param); } else { onRegistrationComplete(); } } catch (Exception ex) { new MessageDialog("Error", ex.Message).ShowAsync(); } this.InitializeComponent(); }