Details on CLBackgroundActivitySession and CLServiceSession Diagnostic enum

I am working with the CLBackgroundActivitySession and CLServiceSession to figure out why our app is sometimes terminated in the background.

I am unable to understand what "insufficientlyInUse" corresponds to, it could be understood as

  1. The location data is not being used enough
  2. the "While in use" permission is not enough

It will be very helpful if the entire enum can be explained, I am attaching the one for CLServiceSession since it is a superset of CLBackgroundActivitySession from CoreLocation

extension CLServiceSession {

    public struct Diagnostic {

        public var authorizationDenied: Bool { get }

        public var authorizationDeniedGlobally: Bool { get }

        public var authorizationRestricted: Bool { get }

        public var insufficientlyInUse: Bool { get }

        public var fullAccuracyDenied: Bool { get }

        public var alwaysAuthorizationDenied: Bool { get }

        public var serviceSessionRequired: Bool { get }

        public var authorizationRequestInProgress: Bool { get }
    }
      ...
}

Looking forward to hearing from you

I found this thread with docstrings for the enums https://github.com/xamarin/xamarin-macios/wiki/CoreLocation-macOS-xcode16.0-b1/b0496539039139e6bfde9e4eeaba45d7eef97636

Follow up question, what qualifies as app not being sufficiently in use?

This broadly means that the operation was suppose to be started/attempted by the app when running in Foreground but instead was attempted from background.

For example :

  • if CLBackgroundActivitySession/CLServiceSession is started from background(which is prohibited) then the diagnostic received will have insufficientlyInUse as True
  • Starting liveUpdates from background with WhenInUse permission will give the same diagnostic.

Note : If your app uses Always authorization then do remember to start Always CLServiceSession from Foreground and hold it for the entire duration of background-location-updates.

Details on CLBackgroundActivitySession and CLServiceSession Diagnostic enum
 
 
Q