private IOSNotificationService(byte[] pP12Data, string pP12PWD) { service = new JdSoft.Apple.Apns.Notifications.NotificationService(false, pP12Data, pP12PWD, 1); service.SendRetries = 5; //5 retries before generating notificationfailed event service.ReconnectDelay = 5000; //5 seconds AddEvents(service); }
private FSNotificationManager() { _apnService = new NotificationService(NotificationSetting.CurrentElement.IsSandBox ,NotificationSetting.CurrentElement.P12File ,NotificationSetting.CurrentElement.P12Pass ,NotificationSetting.Current.Concurrent); }
private IOSNotificationService() { string filepath = ConfigurationManager.AppSettings["P12File"]; string pwd = ConfigurationManager.AppSettings["P12FilePWD"]; service = new JdSoft.Apple.Apns.Notifications.NotificationService(false, filepath, pwd, 1); service.SendRetries = 5; //5 retries before generating notificationfailed event service.ReconnectDelay = 5000; //5 seconds AddEvents(service); }
public Provider(string p12File, string p12FilePassword, bool sandbox ) { string p12Filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p12File); _service = new NotificationService(sandbox, p12Filename, p12FilePassword, 1); _service.SendRetries = 10; //10 retries before generating notificationfailed event _service.ReconnectDelay = 10000; //10 seconds _service.Error += new NotificationService.OnError(service_Error); _service.NotificationTooLong += new NotificationService.OnNotificationTooLong(service_NotificationTooLong); _service.BadDeviceToken += new NotificationService.OnBadDeviceToken(service_BadDeviceToken); _service.NotificationFailed += new NotificationService.OnNotificationFailed(service_NotificationFailed); _service.NotificationSuccess += new NotificationService.OnNotificationSuccess(service_NotificationSuccess); _service.Connecting += new NotificationService.OnConnecting(service_Connecting); _service.Connected += new NotificationService.OnConnected(service_Connected); _service.Disconnected += new NotificationService.OnDisconnected(service_Disconnected); }
public static void SendNotification(string sDeviceToken, string sMessage) { //Variables you may need to edit: //--------------------------------- //True if you are using sandbox certificate, or false if using production bool sandbox = true; //Put your device token in here //string testDeviceToken = "fe58fc8f527c363d1b775dca133e04bff24dc5032d08836992395cc56bfa62ef"; string testDeviceToken = sDeviceToken; //Put your PKCS12 .p12 or .pfx filename here. // Assumes it is in the same directory as your app string p12File = "apn_developer_identity.p12"; //This is the password that you protected your p12File // If you did not use a password, set it as null or an empty string string p12FilePassword = ""; //Actual Code starts below: //-------------------------------- string p12Filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p12File); NotificationService service = new NotificationService(sandbox, p12Filename, p12FilePassword, 1); service.SendRetries = 5; //5 retries before generating notificationfailed event service.ReconnectDelay = 5000; //5 seconds service.Error += new NotificationService.OnError(service_Error); service.NotificationTooLong += new NotificationService.OnNotificationTooLong(service_NotificationTooLong); service.BadDeviceToken += new NotificationService.OnBadDeviceToken(service_BadDeviceToken); service.NotificationFailed += new NotificationService.OnNotificationFailed(service_NotificationFailed); service.NotificationSuccess += new NotificationService.OnNotificationSuccess(service_NotificationSuccess); service.Connecting += new NotificationService.OnConnecting(service_Connecting); service.Connected += new NotificationService.OnConnected(service_Connected); service.Disconnected += new NotificationService.OnDisconnected(service_Disconnected); //The notifications will be sent like this: //Create a new notification to send Notification alertNotification = new Notification(testDeviceToken); alertNotification.Payload.Alert.Body = sMessage; alertNotification.Payload.Sound = "default"; alertNotification.Payload.Badge = 1; //Queue the notification to be sent if (service.QueueNotification(alertNotification)) Console.WriteLine("Notification Queued!"); else Console.WriteLine("Notification Failed to be Queued!"); Console.WriteLine("Cleaning Up..."); //First, close the service. //This ensures any queued notifications get sent befor the connections are closed service.Close(); //Clean up service.Dispose(); Console.WriteLine("Done!"); Console.WriteLine("Press enter to exit..."); Console.ReadLine(); }
static void Main(string[] args) { //Variables you may need to edit: //--------------------------------- //True if you are using sandbox certificate, or false if using production bool sandbox = true; //Put your device token in here string testDeviceToken = "a10c54e8827052b77cd377db98ef739617032710b9378d95ccb847e39bf2562a"; //Put your PKCS12 .p12 or .pfx filename here. // Assumes it is in the same directory as your app string p12File = "apns.p12"; //This is the password that you protected your p12File // If you did not use a password, set it as null or an empty string string p12FilePassword = String.Empty; //Number of notifications to send int count = 1; //Number of milliseconds to wait in between sending notifications in the loop // This is just to demonstrate that the APNS connection stays alive between messages int sleepBetweenNotifications = 15000; //Actual Code starts below: //-------------------------------- string p12Filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p12File); NotificationService service = new NotificationService(sandbox, p12Filename, p12FilePassword, 1); service.SendRetries = 5; //5 retries before generating notificationfailed event service.ReconnectDelay = 5000; //5 seconds service.Error += new NotificationService.OnError(service_Error); service.NotificationTooLong += new NotificationService.OnNotificationTooLong(service_NotificationTooLong); service.BadDeviceToken += new NotificationService.OnBadDeviceToken(service_BadDeviceToken); service.NotificationFailed += new NotificationService.OnNotificationFailed(service_NotificationFailed); service.NotificationSuccess += new NotificationService.OnNotificationSuccess(service_NotificationSuccess); service.Connecting += new NotificationService.OnConnecting(service_Connecting); service.Connected += new NotificationService.OnConnected(service_Connected); service.Disconnected += new NotificationService.OnDisconnected(service_Disconnected); //The notifications will be sent like this: // Testing: 1... // Testing: 2... // Testing: 3... // etc... for (int i = 1; i <= count; i++) { //Create a new notification to send Notification alertNotification = new Notification(testDeviceToken); alertNotification.Payload.Alert.Body = string.Format("Testing {0}...", i); alertNotification.Payload.Sound = "default"; alertNotification.Payload.Badge = i; //Queue the notification to be sent if (service.QueueNotification(alertNotification)) Console.WriteLine("Notification Queued!"); else Console.WriteLine("Notification Failed to be Queued!"); //Sleep in between each message if (i < count) { Console.WriteLine("Sleeping " + sleepBetweenNotifications + " milliseconds before next Notification..."); System.Threading.Thread.Sleep(sleepBetweenNotifications); } } Console.WriteLine("Cleaning Up..."); //First, close the service. //This ensures any queued notifications get sent befor the connections are closed service.Close(); //Clean up service.Dispose(); Console.WriteLine("Done!"); Console.WriteLine("Press enter to exit..."); Console.ReadLine(); }
//Initialize private void Init() { noConnections = 1;//defaut to 1 for testing purposes notificationService = new JdSoftNotifications.NotificationService(IsUnderDevelopment, P12FilePath, P12FilePassword, noConnections); notificationService.SendRetries = 5; //5 retries before generating notificationfailed event notificationService.ReconnectDelay = 5000; //5 seconds notificationService.Error += new JdSoftNotifications.NotificationService.OnError(service_Error); notificationService.NotificationTooLong += new JdSoftNotifications.NotificationService.OnNotificationTooLong(service_NotificationTooLong); notificationService.BadDeviceToken += new JdSoftNotifications.NotificationService.OnBadDeviceToken(service_BadDeviceToken); notificationService.NotificationFailed += new JdSoftNotifications.NotificationService.OnNotificationFailed(service_NotificationFailed); notificationService.NotificationSuccess += new JdSoftNotifications.NotificationService.OnNotificationSuccess(service_NotificationSuccess); notificationService.Connecting += new JdSoftNotifications.NotificationService.OnConnecting(service_Connecting); notificationService.Connected += new JdSoftNotifications.NotificationService.OnConnected(service_Connected); notificationService.Disconnected += new JdSoftNotifications.NotificationService.OnDisconnected(service_Disconnected); }
public static void SendMobileNotification(string UDID, string Message) { var notificationService = new NotificationService(true, HttpContext.Current.Server.MapPath(".") + "/ios_sandbox.p12", "sedona7289", 1); var notification = new Notification(UDID); notification.Payload.Sound = "default"; notification.Payload.Alert.Body = Message; notificationService.QueueNotification(notification); notificationService.Close(); notificationService.Error += notificationService_Error; notificationService.Dispose(); }
public FSNotificationServicePolicyBase(NotificationService apnsService) { if (apnsService!= null) ApnsService = apnsService; _dbContext = new YintaiHangzhouContext(); }