Exemplo n.º 1
0
        public async Task TryAutoStart(INativeAdapter adapter, ILogger logger)
        {
            if (this.CurrentRegistrationToken.IsEmpty())
            {
                return;
            }

            try
            {
                logger.LogInformation("Container has active push registration token - attempting to start");
                var result = await adapter.RequestAccess().ConfigureAwait(false);

                logger.LogDebug($"Auto-Start Permission: {result.Status} - {result.RegistrationToken}");

                if (result.RegistrationToken.IsEmpty())
                {
                    logger.LogDebug("No registration token - removing stored tokens");

                    // TODO: change this?
                    this.ClearRegistration();
                }
                else if (result.RegistrationToken?.Equals(this.CurrentRegistrationToken) ?? false)
                {
                    logger.LogInformation("Push registration token updated");

                    // TODO: change this?
                    this.SetCurrentToken(result.RegistrationToken !, true);
                    await this.OnTokenRefreshed(this.CurrentRegistrationToken !).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                logger.LogWarning("Failed to auto-start push", ex);
            }
        }
Exemplo n.º 2
0
 public PushManager(PushContainer container,
                    INativeAdapter adapter,
                    ILogger <PushManager> logger)
 {
     this.adapter   = adapter;
     this.container = container;
     this.logger    = logger;
 }
Exemplo n.º 3
0
 public PushManager(INativeAdapter native,
                    ILogger <PushManager> logger,
                    PushContainer container,
                    AzureNotificationConfig config)
 {
     this.native    = native;
     this.container = container;
     this.logger    = logger;
     this.config    = config;
 }
Exemplo n.º 4
0
 public PushManager(INativeAdapter adapter,
                    PushContainer container,
                    ILogger <PushManager> logger,
                    AppleLifecycle lifecycle,
                    FirebaseConfiguration?config = null)
 {
     this.adapter   = adapter;
     this.container = container;
     this.logger    = logger;
     this.lifecycle = lifecycle;
     this.config    = config;
 }