void ConfigureAndriod(NotiConfig config) { this.HasAndriod = config.HasAndroid; if (this.HasAndriod) { var setting = new GcmPushChannelSettings(config.GcmSenderId, config.GcmAuthToken, config.GcmPackageName); pushBroker.RegisterGcmService(setting); } }
public NotiPusher(NotiConfig config, string basePath) { pushBroker = new PushBroker(); pushBroker.OnChannelException += OnChannelException; pushBroker.OnDeviceSubscriptionChanged += OnDeviceSubscriptionChanged; pushBroker.OnDeviceSubscriptionExpired += OnDeviceSubscriptionExpired; pushBroker.OnNotificationFailed += OnNotificationFailed; pushBroker.OnServiceException += OnServiceException; ConfigureIos(config, basePath); ConfigureAndriod(config); }
void ConfigureIos(NotiConfig config, string basePath) { this.HasIos = config.HasIos; if (this.HasIos) { try { var path = Path.Combine(basePath, config.ApnCertFile); var bytes = File.ReadAllBytes(path); var setting = new ApplePushChannelSettings(config.ApnProduction, bytes, config.ApnCertPassword); pushBroker.RegisterAppleService(setting); } catch (Exception ex) { logger.Error("Error when adding iOS", ex); this.HasIos = false; } } }