Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GuidanceSpeedMonitor in the Background #155

Open
OllieJohnson-dev opened this issue Jan 31, 2020 · 1 comment
Open

GuidanceSpeedMonitor in the Background #155

OllieJohnson-dev opened this issue Jan 31, 2020 · 1 comment

Comments

@OllieJohnson-dev
Copy link

Hi there,

Im trying to capture the speed Limit of the current road segment a user is travelling along. I wish to do this in the background of the Application.

How can this be achieved.

Im using the following sample code but it will only get speedLimits when the app is in the foreground

extension LMLocationManager: GuidanceSpeedMonitorDelegate {
    public func guidanceSpeedMonitor(_ monitor: GuidanceSpeedMonitor,
                                     didUpdateCurrentSpeed currentSpeed: Measurement<UnitSpeed>?,
                                     isSpeeding: Bool,
                                     speedLimit: Measurement<UnitSpeed>?) {

        let mpsLimit = speedLimit?.converted(to: .metersPerSecond)
        self.currentSpeedLimit = mpsLimit.map { NSNumber(value: $0.value) }

        let mpsSpeed = currentSpeed?.converted(to: .metersPerSecond)
        self.currentSpeed = mpsSpeed.map { NSNumber(value: $0.value) }
        Log.info("SpeedLimit: ", speedLimit)
        if isSpeeding {
            AppModule.auth.user?.journey?.addSpeeding()
        }
    }
}

Thanks
Oliver

@HERE-SDK-Support-Team
Copy link
Contributor

HERE-SDK-Support-Team commented Feb 4, 2020

Hi Oliver,

Apple has very strict policies for apps running in background. Have you already tried to add a UIBackgroundModes key to your app’s Info.plist file? "fetch" or "remote-notification" sounds suitable.

Note that the guidance example app is designed having a UI case in mind, so background tasks are not explicitly supported by default.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants