Example #1
0
        public override Task <AccessState> RequestAccess()
        {
            if (!PlatformExtensions.HasBackgroundMode("fetch"))
            {
                return(Task.FromResult(AccessState.NotSetup));
            }

            var app   = UIApplication.SharedApplication;
            var fetch = BackgroundFetchInterval ?? UIApplication.BackgroundFetchIntervalMinimum;

            app.SetMinimumBackgroundFetchInterval(fetch);
            var status      = app.BackgroundRefreshStatus;
            var grantResult = AccessState.Unknown;

            switch (status)
            {
            case UIBackgroundRefreshStatus.Available:
                grantResult = AccessState.Available;
                break;

            case UIBackgroundRefreshStatus.Denied:
                grantResult = AccessState.Denied;
                break;

            case UIBackgroundRefreshStatus.Restricted:
                grantResult = AccessState.Restricted;
                break;
            }

            return(Task.FromResult(grantResult));
        }
 public JobManager(IServiceProvider container, IRepository repository) : base(container, repository)
 {
     if (PlatformExtensions.HasBackgroundMode("fetch"))
     {
         UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval(BackgroundFetchInterval ?? UIApplication.BackgroundFetchIntervalMinimum);
     }
     //UIApplication.SharedApplication.ObserveValue(UIApplication.BackgroundRefreshStatusDidChangeNotification)
 }
Example #3
0
        public override Task <AccessState> RequestAccess()
        {
            var result = AccessState.Available;

            if (!UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
            {
                result = AccessState.NotSupported;
            }

            else if (iOSExtensions.IsSimulator)
            {
                result = AccessState.NotSupported;
            }

            else if (!PlatformExtensions.HasBackgroundMode("processing"))
            {
                result = AccessState.NotSetup;
            }

            return(Task.FromResult(result));
        }
Example #4
0
        public override async Task <AccessState> RequestAccess()
        {
            if (!PlatformExtensions.HasBackgroundMode("fetch"))
            {
                return(AccessState.NotSetup);
            }

            var app   = UIApplication.SharedApplication;
            var fetch = BackgroundFetchInterval ?? UIApplication.BackgroundFetchIntervalMinimum;

            app.SetMinimumBackgroundFetchInterval(fetch);
            var status      = app.BackgroundRefreshStatus;
            var grantResult = AccessState.Unknown;

            switch (status)
            {
            case UIBackgroundRefreshStatus.Available:
                grantResult = AccessState.Available;
                break;

            case UIBackgroundRefreshStatus.Denied:
                grantResult = AccessState.Denied;
                break;

            case UIBackgroundRefreshStatus.Restricted:
                grantResult = AccessState.Restricted;
                break;
            }

            await this.platform.InvokeOnMainThreadAsync(() =>
                                                        UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval(
                                                            BackgroundFetchInterval ?? UIApplication.BackgroundFetchIntervalMinimum
                                                            )
                                                        );

            //UIApplication.SharedApplication.ObserveValue(UIApplication.BackgroundRefreshStatusDidChangeNotification)

            return(grantResult);
        }