protected void btnPush_Click(object sender, EventArgs e) { //Create our push services broker var push = new PushBroker(); try { if (ddlBids.SelectedItem.Value != null && Convert.ToInt32(ddlBids.SelectedItem.Value) != 0) { //Wire up the events for all the services that the broker registers push.OnNotificationSent += NotificationSent; push.OnNotificationFailed += NotificationFailed; //Apple settings for push string appdatafolder = Server.MapPath("~\\App_Data\\"); var appleCert = File.ReadAllBytes(Path.Combine(appdatafolder, ConfigurationManager.AppSettings["AppleCert"])); //Development = false; Production = True push.RegisterAppleService(new ApplePushChannelSettings(Convert.ToBoolean(ConfigurationManager.AppSettings["IsProduction"]), appleCert, ConfigurationManager.AppSettings["AppleCertPWD"])); push.RegisterWindowsPhoneService(); //fetch all devices for push foreach (var item in GovBidsDAL.FetchDataDeviceTokens()) { switch (item.DeviceType) { case "iOS": //Queue notification push.QueueNotification(new AppleNotification() .ForDeviceToken(item.DeviceToken) .WithAlert(ConfigurationManager.AppSettings["NotificationLabel"] + " : " + GovBidsDAL.FetchDataBidByID(Convert.ToInt32(ddlBids.SelectedItem.Value)).Title) .WithBadge(1) .WithSound(ConfigurationManager.AppSettings["AppleSoundName"])); break; case "WP8": push.QueueNotification(new WindowsPhoneToastNotification() .ForEndpointUri(new Uri(item.DeviceToken)) .ForOSVersion(WindowsPhoneDeviceOSVersion.Eight) .WithBatchingInterval(BatchingInterval.Immediate) .WithNavigatePath("/MainPage.xaml") .WithText1(ConfigurationManager.AppSettings["NotificationLabel"]) .WithText2(GovBidsDAL.FetchDataBidByID(Convert.ToInt32(ddlBids.SelectedItem.Value)).Title)); break; default: break; } } } } catch (Exception) { throw; } finally { //Stop and wait for the queues to drains try { push.StopAllServices(); } catch (Exception) { } push = null; } }