Beispiel #1
0
        public static void RegisterWindowsService(this PushBroker broker, WindowsPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
        {
            var service = new WindowsPushService(new WindowsPushChannelFactory(), channelSettings, serviceSettings);

            broker.RegisterService <WindowsRawNotification>(service);
            broker.RegisterService <WindowsTileNotification>(service);
            broker.RegisterService <WindowsToastNotification>(service);
            broker.RegisterService <WindowsBadgeNumericNotification>(service);
            broker.RegisterService <WindowsBadgeGlyphNotification>(service);
        }
        public static void RegisterWindowsPhoneService(this PushBroker broker, WindowsPhonePushChannelSettings channelSettings, string applicationId, IPushServiceSettings serviceSettings = null)
        {
            var service = new WindowsPhonePushService(new WindowsPhonePushChannelFactory(), channelSettings, serviceSettings);

            broker.RegisterService <WindowsPhoneCycleTileNotification>(service, applicationId);
            broker.RegisterService <WindowsPhoneFlipTileNotification>(service, applicationId);
            broker.RegisterService <WindowsPhoneIconicTileNotification>(service, applicationId);
            broker.RegisterService <WindowsPhoneTileNotification>(service, applicationId);
            broker.RegisterService <WindowsPhoneToastNotification>(service, applicationId);
            broker.RegisterService <WindowsPhoneRawNotification>(service, applicationId);
        }
 public static void RegisterWindowsPhoneService(this PushBroker broker, WindowsPhonePushChannelSettings channelSettings, IPushServiceSettings serviceSettings = null)
 {
     RegisterWindowsPhoneService(broker, channelSettings, null, serviceSettings);
 }
 public static void RegisterWindowsPhoneService(this PushBroker broker, IPushServiceSettings serviceSettings = null)
 {
     RegisterWindowsPhoneService(broker, null, null, serviceSettings);
 }
 public static void RegisterWindowsPhoneService(this PushBroker broker, string applicationId, IPushServiceSettings serviceSettings = null)
 {
     RegisterWindowsPhoneService(broker, null, applicationId, serviceSettings);
 }
Beispiel #6
0
        public static Status sendNotification(string rut, string idNotificationType, string shortText, string longText)
        {
            Status status = new Status();
            SqlConnection conn = new SqlConnection(connectionString: conex);
            rut = removeRut(rut);
            try
            {
                var push = new PushSharp.PushBroker();

                push.OnNotificationSent += NotificationSent;
                push.OnChannelException += ChannelException;
                push.OnServiceException += ServiceException;
                push.OnNotificationFailed += NotificationFailed;
                push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
                push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
                push.OnChannelCreated += ChannelCreated;
                push.OnChannelDestroyed += ChannelDestroyed;          

            

                string selectDevice = @"SELECT D.idDevice, D.idPlataform 
                                        FROM dbo.Device D, dbo.Users_Device UD, dbo.NotificationType_Users NTU
                                        WHERE D.status = 1  AND D.idDevice = UD.idDevice AND NTU.status = 1 AND NTU.idNotificationType = @idNotificationType AND NTU.idUsers = UD.idUsers AND UD.idUsers = @idUsers ";

                
                conn = new SqlConnection(connectionString: conex);
                SqlCommand command = new SqlCommand(selectDevice, conn);

                command.Parameters.AddWithValue("@idUsers", rut);
                command.Parameters.AddWithValue("@idNotificationType", idNotificationType);
                conn.Open();

                SqlDataAdapter daAdaptador = new SqlDataAdapter(command);
                DataSet dtDatos = new DataSet();
                daAdaptador.Fill(dtDatos);

                conn.Close();

                status.status = "Error";
                status.description = "unregistered user";

                string file = System.Configuration.ConfigurationManager.AppSettings["FILE"];
                string password = System.Configuration.ConfigurationManager.AppSettings["PASSWORD"];
                string appID = System.Configuration.ConfigurationManager.AppSettings["APPID"];


                foreach (DataRow _dr in dtDatos.Tables[0].Rows)
                {
                    try
                    {
                        string stext = base64ToText(shortText);
                        string ltext = base64ToText(longText);
                        //var text = Convert.FromBase64String(shortText);
                        if (_dr[1].ToString() == "2")
                        {
                            var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, file));
                            push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, password));
                            push.QueueNotification(new AppleNotification()
                                                       .ForDeviceToken(_dr[0].ToString())
                                                       .WithAlert(stext.ToString())
                                                       .WithBadge(1)
                                                       .WithSound("sound.caf"));
                            push.StopAllServices();
                            status.status = "Success";
                            status.description = "Send iOS";

                            Historical(idNotificationType, rut, _dr[0].ToString(), _dr[1].ToString(), stext, ltext);
                        }
                        else if (_dr[1].ToString() == "1")
                        {
                            push.RegisterGcmService(new GcmPushChannelSettings(appID));

                            push.QueueNotification(new GcmNotification().ForDeviceRegistrationId(_dr[0].ToString())
                                                  .WithJson("{\"alert\":\""+ stext.ToString() +"\",\"badge\":1,\"sound\":\"sound.caf\"}"));
                            push.StopAllServices();
                            status.status = "Success";
                            status.description = "Send Android";

                            Historical(idNotificationType, rut, _dr[0].ToString(), _dr[1].ToString(), stext, ltext);
                        }
                    }
                    catch (Exception ex)
                    {
                        status.status = "Error";
                        status.description = ex.Message;
                    }
                }
               

            }
            catch (Exception ex)
            {
                status.status = "Error";
                status.description = ex.Message;
                conn.Close();
            }
            return status;
        }
Beispiel #7
0
 public static BlackberryNotification BlackberryNotification(this PushBroker broker)
 {
     return(new BlackberryNotification());
 }
Beispiel #8
0
 public static AppleNotification AppleNotification(this PushBroker broker)
 {
     return(new AppleNotification());
 }
Beispiel #9
0
 public static void RegisterAppleService(this PushBroker broker, ApplePushChannelSettings channelSettings, IPushServiceSettings serviceSettings = null)
 {
     RegisterAppleService(broker, channelSettings, null, serviceSettings);
 }
Beispiel #10
0
 public static WindowsToastNotification WindowsToastNotification(this PushBroker broker)
 {
     return(new WindowsToastNotification());
 }
 public static GcmNotification GcmNotification(this PushBroker broker)
 {
     return(new GcmNotification());
 }
 public static void RegisterGcmService(this PushBroker broker, GcmPushChannelSettings channelSettings, string applicationId, IPushServiceSettings serviceSettings = null)
 {
     broker.RegisterService <GcmNotification>(new GcmPushService(new GcmPushChannelFactory(), channelSettings, serviceSettings), applicationId);
 }
 public static void RegisterChromeGcmService(this PushBroker broker, ChromePushChannelSettings channelSettings, IPushServiceSettings serviceSettings = null)
 {
     broker.RegisterService <ChromeNotification>(new ChromePushService(channelSettings, serviceSettings));
 }
 public static C2dmNotification C2dmNotification(this PushBroker broker)
 {
     return(new C2dmNotification());
 }
 public static ChromeNotification ChromeNotification(this PushBroker broker)
 {
     return(new ChromeNotification());
 }
Beispiel #16
0
 public static WindowsBadgeGlyphNotification WindowsBadgeGlyphNotification(this PushBroker broker)
 {
     return(new WindowsBadgeGlyphNotification());
 }
 public static WindowsPhoneRawNotification WindowsPhoneRawNotification(this PushBroker broker)
 {
     return(new WindowsPhoneRawNotification());
 }
Beispiel #18
0
 public static void RegisterAdmService(this PushBroker broker, AdmPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
 {
     broker.RegisterService <AdmNotification>(new AdmPushService(new AdmPushChannelFactory(), channelSettings, serviceSettings));
 }
Beispiel #19
0
 public static void RegisterAppleService(this PushBroker broker, ApplePushChannelSettings channelSettings, string applicationId, IPushServiceSettings serviceSettings = null)
 {
     broker.RegisterService <AppleNotification>(new ApplePushService(channelSettings, serviceSettings), applicationId);
 }
 /// <summary>
 /// Registers FirefoxOS service.
 /// </summary>
 ///
 /// <param name="broker">Registration broker.</param>
 public static void RegisterFirefoxOSService(this PushBroker broker)
 {
     broker.RegisterService <FirefoxOSNotification>(new FirefoxOSPushService());
 }
Beispiel #21
0
 public static void RegisterBlackberryService(this PushBroker broker, BlackberryPushChannelSettings channelSettings, string applicationId = null, IPushServiceSettings serviceSettings = null)
 {
     broker.RegisterService <BlackberryNotification>(new BlackberryPushService(channelSettings, serviceSettings), applicationId);
 }
 /// <summary>
 /// Create a new instance of the <see cref="FirefoxOSNotification"/> class.
 /// </summary>
 ///
 /// <param name="broker">Registration broker.</param>
 ///
 /// <returns>Created notification object.</returns>
 public static FirefoxOSNotification FirefoxOSNotification(this PushBroker broker)
 {
     return(new FirefoxOSNotification());
 }
Beispiel #23
0
 public static void RegisterBlackberryService(this PushBroker broker, BlackberryPushChannelSettings channelSettings, IPushServiceSettings serviceSettings = null)
 {
     RegisterBlackberryService(broker, channelSettings, null, serviceSettings);
 }
Beispiel #24
0
 public static void RegisterBISService(this PushBroker broker, BISPushChannelSettings channelSettings, IPushServiceSettings serviceSettings = null)
 {
     broker.RegisterService <BISNotification>(new BISPushService(channelSettings, serviceSettings));
 }