Example #1
0
 void ConfigureAndriod(NotiConfig config)
 {
     this.HasAndriod = config.HasAndroid;
     if (this.HasAndriod)
     {
         var setting = new GcmPushChannelSettings(config.GcmSenderId, config.GcmAuthToken, config.GcmPackageName);
         pushBroker.RegisterGcmService(setting);
     }
 }
Example #2
0
        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);
        }
Example #3
0
        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;
                }
            }
        }