3 Replies
      Latest reply on Feb 27, 2020 12:26 PM by sryu
      Scriptkiddy Level 1 Level 1 (0 points)

        I was trying to implement the BGTaskScheduler but couldn't get it working than tried it with the sample project provided by Apple. I tried to run it on latest Xcode beta and latest iOS beta but can't get the background tasks to work. I tried the BGAppRefreshTaskRequest, didn't modify that and slighty modified BGProcessingTaskRequest so it would also be scheduled every x minutes. But in the console you can see it keeps rejecting it.

         

        Example of the console:

        bgRefresh-com.example.apple-samplecode.ColorFeed.refresh:63693C:[

          {name: DataBudgetPolicy, policyWeight: 1.000, response: {Decision: Must Not Proceed, Score: 0.00, Rationale: [{[/system/budgets/networking]: Required:1.00, Observed:0.00},]}}

        ], FinalDecision: Must Not Proceed}

         

        bgProcessing-com.example.apple-samplecode.ColorFeed.db_cleaning:E319C7:[

          {name: ApplicationPolicy, policyWeight: 50.000, response: {Decision: Must Not Proceed, Score: 0.00}}

          {name: DeviceActivityPolicy, policyWeight: 5.000, response: {Decision: Must Not Proceed, Score: 0.00, Rationale: [{launchType == PROCESSING AND deviceActive == 1}]}}

        ], FinalDecision: Must Not Proceed}

         

        I tried everything I could think of. Even when the iPhone X is fully charged and on charger, it doesn't matter.

         

        The implementation looks quite simple but if the sample code doesn't even run correct what else could you do.

         

        Can someone help me please?

        • Re: BGTaskScheduler ColorFeed sample project doesn't work
          l00 Level 1 Level 1 (0 points)

          I have the same problem. Did everything according to the WWDC video and I can trigger execution via lldb _simulateLaunchForTaskWithIdentifier, but other than that, it's never executed. Is there any way to analyze whats going on?

            • Re: BGTaskScheduler ColorFeed sample project doesn't work
              pdewaalSS Level 1 Level 1 (0 points)

              Also interested in hearing anyone that has gotten BGProcessingTasks or BGAppRefreshTasks to trigger in the "real world". Nothing I do seems to make a difference and no projects that are supposed to "teach" how-to use them work.

                • Re: BGTaskScheduler ColorFeed sample project doesn't work
                  sryu Level 1 Level 1 (0 points)

                  I have the same issue. Too many things seem to conspire to prevent it from actually happening.

                   

                  1) Thermal state

                  2) CPU usage

                  3) a mysterious Device Activity Policy

                  4) Thundering herd event, which seems to require at least 15 minutes before relenting

                  5) and finally this "DataBudgetPolicy, policyWeight: 1.000, response: {Decision: Must Not Proceed, Score: 0.00, Rationale: [{[/system/budgets/networking", which happens reliably whenever I switch from Wifi to cellular (I have ATT unlimited) - very occasionally, it seems to work in the wee hours - maybe I was hallucinating...., but during the day, the problem happens most reliably.

                   

                  I understand Apple's issue with too many apps trying to grab precious background resources with dynamic fluctuations, but trying to juggle a few ad-hoc criteria to allow/reject background notifications and/or background tasks is just inviting trouble.

                   

                  My app requires only a few robust silent push notifications that can wake up the app from suspension, but without requiring user intervention. It is probably a relatively feather-weight requirement(**) compared to various other usage scenarios, but as of now, I cannot achieve that. Apple should at least allow a budget, i.e. a number of total such tasks allowed per day per app before being limited by these intractable constraints.

                  Personally, I wouldn't mind having just about a dozen such BGRefresh events allowed per day unconditionally before being shut out for the rest of the cycle. Is this asking too much?

                  (**: parsing a simple payload in the silent notification and adjust the app badge icon number accordingly.)