blackberry/BB10-WebWorks-Framework

No access to GPS when app is minimized or display sleeps

Closed this issue · 10 comments

Hi TeamBlackBerry,

for my app, which is in development, i need access to GPS - also wenn the device is sleeping and the app is running backgrounded.

I found this Issue:
It is not possible to get GPS Access in a specific intervall via "getCurrentPosition" when webworks app is running in background (minimized / thumbnail / display sleeps).

In the config.xml I set the "run_when_backgrounded" and of corse the "access_location_services" permits.

When my app is active in the foreground and the display is not sleeping i have access to the location services.
When my app i running in background i can make console logs in a specific intervall but no access to the location services.

When i set a timeout in the "getCurrentPosition" function i will get a timeout JavaScript Alert.

I also made this Post in the Forum:
http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/quot-run-when-backgrounded-quot-isn-t-supporting-GPS/td-p/2210623

And i also talked about this problem with Luca Sale at the MobileTechConference in Munich last Tuesday.

Would be very nice if this could be fixed in the near future :-)

Thanks a lot in advance
Lars.

Maybe this is a security feature, to make it impossible for applications to track the user continously?

I don´t think so - cause i found this in the cascades documentation:

#############################
Getting updates in the background
If you want your app to continue to get location fixes while your app is in the background or minimized, you must set the canRunInBackground property to true. For example, this could be used by a fleet tracking application that needs to update the dispatch office with the current location of the vehicle while the app is minimized.
#############################

Yes i know - webworks != cascades - but if it is a security feature then it also schould be a security feature in cascades - or better - it should work in webworks ;-)

WatchPosition works fine for me in the background. I had issues with an older build of the SDK when the screen was turned off, but this has been fixed in 1.0.4.7 if I remember correctly. 

good to know that this works for you - so i hope there will be a way getting "getCurrentPosition" to work also.

I started with 1.0.4.7.
But also with 1.0.4.11 it doesn´t work for me.

Have you tried navigator.geolocation.watchPosition instead of getCurrentPosition?

Thanks for the info that watchPosition is running in the background.

I made a small sample app and i can confirm:
watchPosition is running - also wenn app is backgrounded on my system.

I can make a workaround with watchPosition.
Perhaps the getCurrentPostion will be fixed in one of the next versions to run that function in background..?

Well I think getCurrentPosition is not designed to be running in the background, but I'm not that deep into W3C Specifications so maybe you are right @larsgentz that this is a bug, but I believe this is the expected behavior.

getCurrentPosition is more designed for a single request sort of use case. watchPosition is the API intended to be used if you need periodic updates.


This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.

Try the following:

  • connect to webinspector
  • background the app
  • run the following in the console: navigator.geolocation.getCurrentPosition(function () { console.log(arguments); });

I was able to get data while backgrounded.

I refactored my app to use the watchPosition function - this seems to work well - also when app is backgrounded.
Thanks a lot - closing this thread :-)