public ApplePushService(IPushChannelFactory pushChannelFactory, ApplePushChannelSettings channelSettings, IPushServiceSettings serviceSettings) : base(pushChannelFactory ?? new ApplePushChannelFactory(), channelSettings, serviceSettings) { var appleChannelSettings = channelSettings; cancelTokenSource = new CancellationTokenSource(); //allow control over feedback call interval, if set to zero, don't make feedback calls automatically if (appleChannelSettings.FeedbackIntervalMinutes > 0) { feedbackService = new FeedbackService(); feedbackService.OnFeedbackReceived += feedbackService_OnFeedbackReceived; feedbackService.OnFeedbackException += (Exception ex) => this.RaiseServiceException(ex); if (timerFeedback == null) { timerFeedback = new Timer(new TimerCallback((state) => { try { feedbackService.Run(channelSettings as ApplePushChannelSettings, this.cancelTokenSource.Token); } catch (Exception ex) { base.RaiseServiceException(ex); } //Timer will run first after 10 seconds, then every 10 minutes to get feedback! }), null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(appleChannelSettings.FeedbackIntervalMinutes)); } } //Apple has documented that they only want us to use 20 connections to them base.ServiceSettings.MaxAutoScaleChannels = 20; }
public ApplePushService(IPushChannelFactory pushChannelFactory, ApplePushChannelSettings channelSettings, IPushServiceSettings serviceSettings) : base(pushChannelFactory ?? new ApplePushChannelFactory(), channelSettings, serviceSettings) { var appleChannelSettings = channelSettings; cancelTokenSource = new CancellationTokenSource(); //allow control over feedback call interval, if set to zero, don't make feedback calls automatically if (appleChannelSettings.FeedbackIntervalMinutes > 0) { feedbackService = new FeedbackService(); feedbackService.OnFeedbackReceived += feedbackService_OnFeedbackReceived; feedbackService.OnFeedbackException += (Exception ex) => this.RaiseServiceException (ex); if (timerFeedback == null) { timerFeedback = new Timer(new TimerCallback((state) => { try { feedbackService.Run(channelSettings as ApplePushChannelSettings, this.cancelTokenSource.Token); } catch (Exception ex) { base.RaiseServiceException(ex); } //Timer will run first after 10 seconds, then every 10 minutes to get feedback! }), null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(appleChannelSettings.FeedbackIntervalMinutes)); } } //Apple has documented that they only want us to use 20 connections to them base.ServiceSettings.MaxAutoScaleChannels = 20; }
public ApplePushService(IPushChannelFactory pushChannelFactory, ApplePushChannelSettings channelSettings, IPushServiceSettings serviceSettings) : base(pushChannelFactory ?? (IPushChannelFactory) new ApplePushChannelFactory(), (IPushChannelSettings)channelSettings, serviceSettings) { ApplePushService applePushService = this; ApplePushChannelSettings pushChannelSettings = channelSettings; this.cancelTokenSource = new CancellationTokenSource(); if (pushChannelSettings.FeedbackIntervalMinutes > 0) { this.feedbackService = new FeedbackService(); this.feedbackService.OnFeedbackReceived += new FeedbackService.FeedbackReceivedDelegate(this.feedbackService_OnFeedbackReceived); this.feedbackService.OnFeedbackException += (FeedbackService.FeedbackExceptionDelegate)(ex => applePushService.RaiseServiceException(ex)); if (this.timerFeedback == null) { this.timerFeedback = new Timer((TimerCallback)(state => { try { applePushService.feedbackService.Run(channelSettings, applePushService.cancelTokenSource.Token); } catch (Exception ex) { applePushService.RaiseServiceException(ex); } }), (object)null, TimeSpan.FromSeconds(10.0), TimeSpan.FromMinutes((double)pushChannelSettings.FeedbackIntervalMinutes)); } } this.ServiceSettings.MaxAutoScaleChannels = 20; }
public ApplePushService(ApplePushChannelSettings channelSettings, PushServiceSettings serviceSettings = null) : base(new ApplePushChannelFactory(channelSettings), serviceSettings) { var appleChannelSettings = channelSettings; cancelTokenSource = new CancellationTokenSource(); feedbackService = new FeedbackService(); feedbackService.OnFeedbackReceived += this.feedbackService_OnFeedbackReceived; // allow control over feedback call interval, if set to zero, don't make feedback calls automatically if (appleChannelSettings.FeedbackIntervalMinutes > 0) { timerFeedback = new Timer( state => { try { this.feedbackService.Run( channelSettings, this.cancelTokenSource.Token); } catch (Exception ex) { this.Events.RaiseChannelException(ex, PlatformType.Apple); } // Timer will run first after 10 seconds, then every 10 minutes to get feedback! }, null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(appleChannelSettings.FeedbackIntervalMinutes)); } }
public ApplePushService(PushChannelSettings channelSettings, PushServiceSettings serviceSettings = null) : base(channelSettings, serviceSettings) { cancelTokenSource = new CancellationTokenSource(); feedbackService = new FeedbackService(); feedbackService.OnFeedbackReceived += new FeedbackService.FeedbackReceivedDelegate(feedbackService_OnFeedbackReceived); timerFeedback = new Timer(new TimerCallback((state) => { feedbackService.Run(channelSettings as ApplePushChannelSettings, this.cancelTokenSource.Token); //Timer will run first after 10 seconds, then every 10 minutes to get feedback! }),null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(10)); }
private static void ReceiveFeedback() { FeedbackService fs = new FeedbackService(); fs.OnFeedbackReceived += Fs_OnFeedbackReceived; // var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../Resources/PushSharp.Apns.Sandbox.p12")); // ApplePushChannelSettings appleSettings = new ApplePushChannelSettings (false, appleCert, "Lize4Rune"); var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../Resources/OLBPhoneSandboxCertificate.p12")); ApplePushChannelSettings appleSettings = new ApplePushChannelSettings(false, appleCert, "0lbSandb0x"); fs.Run(appleSettings); }
public void APNS_Feedback_Service () { var config = new ApnsConfiguration ( ApnsConfiguration.ApnsServerEnvironment.Sandbox, Settings.Instance.ApnsCertificateFile, Settings.Instance.ApnsCertificatePassword); var fbs = new FeedbackService (config); fbs.FeedbackReceived += (string deviceToken, DateTime timestamp) => { // Remove the deviceToken from your database // timestamp is the time the token was reported as expired }; fbs.Check (); }
public ApplePushService(ApplePushChannelSettings channelSettings, PushServiceSettings serviceSettings) : base(channelSettings, serviceSettings) { var appleChannelSettings = channelSettings as ApplePushChannelSettings; //cancelTokenSource = new CancellationTokenSource(); feedbackService = new FeedbackService(); feedbackService.OnFeedbackReceived += new FeedbackService.FeedbackReceivedDelegate(feedbackService_OnFeedbackReceived); //allow control over feedback call interval, if set to zero, don't make feedback calls automatically if (appleChannelSettings.FeedbackIntervalMinutes > 0) { timerFeedback = new Timer(new TimerCallback((state) => { try { feedbackService.Run(channelSettings as ApplePushChannelSettings /*, this.cancelTokenSource.Token*/); } catch (Exception ex) { this.Events.RaiseChannelException(ex); } //Timer will run first after 10 seconds, then every 10 minutes to get feedback! }), null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(appleChannelSettings.FeedbackIntervalMinutes)); } }
private void InitApnsBroker(GlobalSettings globalSettings, IHostingEnvironment hostingEnvironment) { if(string.IsNullOrWhiteSpace(globalSettings.Push.ApnsCertificatePassword) || string.IsNullOrWhiteSpace(globalSettings.Push.ApnsCertificateThumbprint)) { return; } var apnsCertificate = GetCertificate(globalSettings.Push.ApnsCertificateThumbprint); if(apnsCertificate == null) { return; } var apnsConfig = new ApnsConfiguration(hostingEnvironment.IsProduction() ? ApnsConfiguration.ApnsServerEnvironment.Production : ApnsConfiguration.ApnsServerEnvironment.Sandbox, apnsCertificate.RawData, globalSettings.Push.ApnsCertificatePassword); _apnsBroker = new ApnsServiceBroker(apnsConfig); _apnsBroker.OnNotificationFailed += ApnsBroker_OnNotificationFailed; _apnsBroker.OnNotificationSucceeded += (notification) => { Debug.WriteLine("Apple Notification Sent!"); }; _apnsBroker.Start(); var feedbackService = new FeedbackService(apnsConfig); feedbackService.FeedbackReceived += FeedbackService_FeedbackReceived; feedbackService.Check(); }
private void CheckAndRemoveExpiredToken() { try { var fbs = new FeedbackService(config); fbs.FeedbackReceived += (string deviceToken, DateTime timestamp) => { notificationService.Unsubscribe(deviceToken, userId); }; fbs.Check(); } catch (Exception e) { logger.ErrorFormat("Unable to usubscibed token" + e.Message); } }