コード例 #1
0
ファイル: JobManager.cs プロジェクト: tuaasn/shiny
        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));
        }
コード例 #2
0
 public JobManager(IServiceProvider container, IRepository repository) : base(container, repository)
 {
     if (PlatformExtensions.HasBackgroundMode("fetch"))
     {
         UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval(BackgroundFetchInterval ?? UIApplication.BackgroundFetchIntervalMinimum);
     }
     //UIApplication.SharedApplication.ObserveValue(UIApplication.BackgroundRefreshStatusDidChangeNotification)
 }
コード例 #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));
        }
コード例 #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);
        }