public WebPushPushNotificationService(IOptions <PushNotificationServiceOptions> options)
        {
            _options = options.Value;

            _pushClient = new WebPushClient();
            _pushClient.SetVapidDetails(_options.Subject, _options.PublicKey, _options.PrivateKey);
        }
        public PushServicePushNotificationService(IOptions<PushNotificationServiceOptions> optionsAccessor, IVapidTokenCache vapidTokenCache, PushServiceClient pushClient, ILogger<PushServicePushNotificationService> logger)
        {
            _options = optionsAccessor.Value;

            _pushClient = pushClient;
            _pushClient.DefaultAuthentication = new VapidAuthentication(_options.PublicKey, _options.PrivateKey)
            {
                Subject = _options.Subject,
                TokenCache = vapidTokenCache
            };

            _logger = logger;
        }
        public PushServicePushNotificationService(IOptions <PushNotificationServiceOptions> optionsAccessor, IVapidTokenCache vapidTokenCache, PushServiceClient pushClient, ILogger <PushServicePushNotificationService> logger)
        {
            _options = optionsAccessor.Value;

            _pushClient = pushClient;
            _pushClient.DefaultAuthentication = new VapidAuthentication("BPggdcXPKdvSpyjQHXlufrPQ7YPs_3TsoMnrDkg3wJ7mc-6l2fXEzjJlAopRaWdR1f5MRpxil68rLqDpYFp-YN0", "dO6qPKtyBD9TWsOksZqA527DplqID0czx-K1-LqjynU")
            {
                Subject    = "mailto:[email protected]",
                TokenCache = vapidTokenCache
            };

            _logger = logger;
        }
Exemplo n.º 4
0
        public async Task CloudMessage_CanDryRun()
        {
            // Arrange
            PushNotificationServiceOptions pushOptions = new PushNotificationServiceOptions()
            {
                FCMServerToken = ""
            };
            IOptions <PushNotificationServiceOptions> options = Options.Create(pushOptions);
            IPushNotificationService pushService = new FCMPushNotificationService(options, GetContextWithData());
            NotificationRequest      apnsRequest = GetApnsRequest();

            //Act
            List <NotificationResult> result = await pushService.NotifyAsync(apnsRequest);

            //Assert
            Assert.NotEmpty(result);
        }