private void registerTokenIfNecessary(AndroidDependencyContainer dependencyContainer)
        {
            var userLoggedIn = dependencyContainer.UserAccessManager.CheckIfLoggedIn();

            if (!userLoggedIn)
            {
                return;
            }

            var shouldBeSubscribedToPushNotifications = dependencyContainer
                                                        .RemoteConfigService
                                                        .GetPushNotificationsConfiguration()
                                                        .RegisterPushNotificationsTokenWithServer;

            if (!shouldBeSubscribedToPushNotifications)
            {
                return;
            }

            dependencyContainer.InteractorFactory.SubscribeToPushNotifications()
            .Execute()
            .ObserveOn(dependencyContainer.SchedulerProvider.BackgroundScheduler)
            .Subscribe(_ => StopSelf())
            .DisposedBy(disposeBag);
        }
Пример #2
0
        private async void onHandleIntentAsync(Intent intent)
        {
            AndroidDependencyContainer.EnsureInitialized(Application.Context);
            AndroidDependencyContainer.Instance.WidgetsService.Start();

            var action = intent.Action;

            switch (action)
            {
            case StartTimeEntryAction:
                await handleStartTimeEntry();

                break;

            case StopRunningTimeEntryAction:
                await handleStopRunningTimeEntry();

                break;

            case SuggestionTapped:
                await continueTimeEntryFromSuggestion(intent);

                break;

            default:
                throw new InvalidOperationException($"Cannot handle intent with action {action}");
            }

            StopForeground(true);
        }
Пример #3
0
        public override bool OnStartJob(JobParameters @params)
        {
            // Background sync for Android 10 is temporary disabled due to a crash on Android 10 that is hard to reproduce
            // Calling JobFinished and returning early here stops the background job from running
            if (QApis.AreAvailable)
            {
                JobFinished(@params, false);
                return(false);
            }

            AndroidDependencyContainer.EnsureInitialized(ApplicationContext);
            var dependencyContainer = AndroidDependencyContainer.Instance;

            if (!dependencyContainer.UserAccessManager.CheckIfLoggedIn())
            {
                return(false);
            }

            disposable = dependencyContainer.InteractorFactory.RunBackgroundSync()
                         .Execute()
                         .Subscribe(DoNothing, DoNothing,
                                    () => JobFinished(@params, false));

            return(true);
        }
        public override void OnTokenRefresh()
        {
            AndroidDependencyContainer.EnsureInitialized(Application.Context);

            var dependencyContainer = AndroidDependencyContainer.Instance;

            registerTokenIfNecessary(dependencyContainer);
        }
Пример #5
0
        public override bool OnStartJob(JobParameters @params)
        {
            AndroidDependencyContainer.EnsureInitialized(ApplicationContext);
            var dependencyContainer = AndroidDependencyContainer.Instance;

            if (!dependencyContainer.UserAccessManager.CheckIfLoggedIn())
            {
                return(false);
            }

            disposable = dependencyContainer.SyncManager
                         .PullTimeEntries()
                         .Subscribe(DoNothing, DoNothing,
                                    () => JobFinished(@params, false));

            return(true);
        }