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

Background Ranging stops after 3 minutes #45

Open
wallanoo opened this issue Mar 2, 2016 · 15 comments
Open

Background Ranging stops after 3 minutes #45

wallanoo opened this issue Mar 2, 2016 · 15 comments

Comments

@wallanoo
Copy link

wallanoo commented Mar 2, 2016

Hi @RBAtkins0n , @williamrijksen

I've started this discussion in issue #37

I've coded an app that have to perform region monitoring and continuous ranging in background, as defined in

(https://community.estimote.com/hc/en-us/articles/203914068-Is-it-possible-to-use-beacon-ranging-in-the-background-)

I be careful to strictly follow the instructions (added permissions and background mode in tiapp.xml, tried a background service etc.), thanks to @RBAtkins0n and @williamrijksen

so my app is able to notify if a beacon is entering/exiting the region, even if it happens after many minutes.

Unfortunately, ranging ALWAYS stops after 2-3 minutes, no way.

I'm working with 0.11.0 module, Titanium SDK 5.1.2, Xcode 6.2

Maybe I miss something obvious, my code is quite simple and it seems all ok...

I attach the code here, I actually do not know how to fix it...

files.zip

thanks for all in advance

@appinlet
Copy link

appinlet commented Mar 2, 2016

Hi @wallanoo!

I will be able to assist you with my solution re a background service and determinedRegionState events, but am unable to detail it all immediately. It took me days of trial and error to find a solution, so I would like to save you the hassle. Will respond to this thread as soon as I am able. Working on some other PHP projects at the mo.

@wallanoo
Copy link
Author

wallanoo commented Mar 2, 2016

thanks a lot @RBAtkins0n

the determinedRegionState now is clear.
The main issue is the background monitoring that stops after 3 minutes... take your time, and thank you in advance

@wallanoo
Copy link
Author

Hi,

any new about it?

I've googled, and it seems that in iOS9: Setting allowsBackgroundLocationUpdates = YES on CLLocationManager seems to solve the background ranging problem.
However, it seems the solution for native code, how can be done in titanium? Maybe it needs a module update?

here the topic: http://stackoverflow.com/questions/32478169/ibeacon-ranging-in-background

thanks

@roelandp
Copy link

Hi,

I'm running a test with this module. I'm integrating this app with an app which is already available for GPS (background location enabled in PLIST)

I found out that in my app the background notifications for ibeacon keep running / notifying (ranging events) to the app (i see it in my log) also after the 3 minutes.
In this app the 'GPS' evenlistener for titanium is also active, so this might be of help for you?

kind regards, roeland

On 24 Mar 2016, at 12:53, wallanoo [email protected] wrote:

Hi,

any new about it?

I've googled, and it seems that in iOS9: Setting allowsBackgroundLocationUpdates = YES on CLLocationManager seems to solve the background ranging problem.
However, it seems the solution for native code, how can be done in titanium? Maybe it needs a module update?

here the topic: http://stackoverflow.com/questions/32478169/ibeacon-ranging-in-background http://stackoverflow.com/questions/32478169/ibeacon-ranging-in-background
thanks


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub #45 (comment)

@wallanoo
Copy link
Author

It could be a good try..

what do you have exactly in your tiapp.xml concerning location tags for info.plist?

@roelandp
Copy link

 <key>UIBackgroundModes</key>
 <array>
    <string>audio</string>
    <string>location</string>
    <string>remote-notification</string>
</array>

<key>NSLocationAlwaysUsageDescription</key>
<string>
    DESCRIPTION HERRRRRE
</string>

But of course the audio & remote-notification values are not necessary (it's an audio enabled app and also sends occasional remote notification through APNS).

@wallanoo
Copy link
Author

thanks a lot @RBAtkins0n
Now I've added the GPS background location (without audio and occasional remote notification, of course) and ranging is working in background (I'm running it from 45 minutesand it is still background ranging)

However, it is a workaround for an existing module issue, so it could be useful to fix it (I'm not able to fix module's code on github, but maybe setting allowsBackgroundLocationUpdates = YES on CLLocationManager or something else could fix it, in order to avoid problems on iOS updates)

Thanks for all anyway

@roelandp
Copy link

No problem @wallanoo (my name is roeland btw 😄 ). Great to hear that you got it running.

I think ultimately you should have something like:

  1. Have Monitoring (location always usage + background location allowed) running for the given UUID.
  2. Whenever the monitoring event is fired see if you can start a 'ranging' through the background service
  3. Act upon the found beacons, stop the ranging.

This is what I would pursue in your case I guess... However I have not implemented this technique so I can't help you with that

@wallanoo
Copy link
Author

wallanoo commented Apr 1, 2016

ok Roeland, good suggestion

@Astrovic
Copy link

When is trigged determinedRegionState event? It never appears on my test app..

@wallanoo
Copy link
Author

Actually it never appears in my app too, it was just for test..

@Astrovic
Copy link

Ok. I need a function similar to yours, I have to monitor the enter/exit in a region, even in the background. I tried your files.zip and added localization in tiapp.xml, and it seems to work. You have further optimized the code?
Thank you :)

@wallanoo
Copy link
Author

not for now.. maybe in the future

@Astrovic
Copy link

But if I enabled background location in PLIST (NSLocationAlwaysUsageDescription), I can avoid using a background service (Ti.App.iOS.registerBackgroundService) then? Or is it better to use the background service also?

@wallanoo
Copy link
Author

It still works also without registering a background service in my app

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

4 participants