GeofencePlugin icon indicating copy to clipboard operation
GeofencePlugin copied to clipboard

OnRegionStateChanged - never get executed

Open walnut-co opened this issue 6 years ago • 6 comments

OnRegionStateChanged never gets executed ? and OnLocationChanged get called repeatedly.

and any plans for sample ?

walnut-co avatar Aug 16 '18 04:08 walnut-co

I had the same problem and found that it only occurred when I was targetting Android 8.0 or higher. When I rolled the target back to Android 7.0 then OnRegionStateChanged started working again (even running on an Android 8 device).

This is a short-term fix though, as Google is not accepting new apps that target Android 7.0 and current apps have until the end of the year (2018) to update.

willsam100 avatar Aug 30 '18 18:08 willsam100

I had the same problem and found that it only occurred when I was targetting Android 8.0 or higher. When I rolled the target back to Android 7.0 then OnRegionStateChanged started working again (even running on an Android 8 device).

This is a short-term fix though, as Google is not accepting new apps that target Android 7.0 and current apps have until the end of the year (2018) to update.

I tried this fix but it only results in OnLocationChanged being called repeatedly and OnRegionStateChanged only being called once at the very start of the app. I can't make it work :(

Isn't there any project sample?

manzha avatar Sep 13 '18 19:09 manzha

I am also having this issue, any help?

HeroXx avatar Oct 14 '18 10:10 HeroXx

I am not sure if the problem was because I was debugging using a physical device and an application for mocking locations, as for android API 26, this technique (mocking locations in device) is not working correctly with some apps (it constantly jumped from original location to mock location). I became aware of this days laters (too late as I was using a different approach to my problem).

So my advice would be to try debug it while walking in real time, and not using mockup locations (at least for android, not sure ios).

manzha avatar Oct 15 '18 18:10 manzha

Any ETA on fixing this for Android 8.0 and above? I’m noticing this same exact behavior. I have an app in production that heavily uses this.

patkozlowski avatar Nov 10 '18 01:11 patkozlowski

I had to modify the API to get this to work with my specific use case. This does work for Android 8 and above, but I had to start the service as a foreground service, or else you will get some illegal state exception due to android 8 background service limitations, maybe that could be implemented into the project in the future. I've also noticed that builder.SetInitialTrigger(GeofencingRequest.InitialTriggerDwell) worked for me as I want to be notified when starting the geofence, after the dwelling time for the user to be notified. You can set based upon your specific use case to use the defaulted InitialTriggerEnter or even builder.SetInitialTrigger(GeofencingRequest.InitialTriggerDwell | GeofeningRequest.InitialTriggerEnter). I use on a real device and test using an app called "Fake GPS" which works pretty well of mocking and changing locations for testing.

For iOS you can follow this youtube video for spoofing your gps on the real device. The workflow I use is to have the app already loaded on your phone (you can't debug though, as you will be running the blank "gps spoofer app" in xcode). Change the coordinates in the black app, and see the gps changes reflected in the app using the geofencing api.

patkozlowski avatar Jan 24 '19 22:01 patkozlowski