distriqt / airnativeextensions

DEPRECATED: Original repository of the distriqt native extensions and is no longer maintained. Please see our site for the latest ANEs
https://airnativeextensions.com
2 stars 0 forks source link

Handling BeaconEvent.REGION_ENTER on Android is different than on iOS #272

Closed amodo-dev closed 8 years ago

amodo-dev commented 9 years ago

Hi guys, This may not be a BUG, but actually something to do with different handling of Beacons on iOS and Android.

This has been giving me a headache for several days now. After failing to make it work in my app, I have tried your example but the result is the same. It works fine on Android, but not on iOS. I've tested the example on several iPhones and iPads, but I simply cannot get it to work properly. Or at least the way i think it should work :)

Starting monitoring for a region on Android ALWAYS triggers REGION_ENTER event, (if the phone is in the region, of course). And this happens regardless of what was previously going on.

The behavior is different on iOS. On iOS when re-starting to monitor for a region, the REGION_ENTER will trigger only if REGION_EXIT was previously triggered. It is as though the operating system remembers that the phone was in that region and never left, even if the beacon was turned off or the phone exited the region but did not trigger the REGION_EXIT event before it started to monitor for regions again.

Apparently beacon regions on iOS are somewhat like "Hotel California" - you can check out, but you can (almost) never leave :)

To me it seems preferable that if I stop monitoring for regions, I automatically exit all regions. This is what seems to be happening on Android. Starting monitoring triggers REGION_ENTER no matter what.

On iOS this is not the case. If I stop monitoring for regions, and later start again, REGION_ENTER does not trigger, because REGION_EXIT never had a chance to trigger. Stopping monitoring does not make the system forget the region I was in.

What is your take on this? Is there a way to make the iOS forget the regions it is in, so that when an app starts monitoring for a region, it "starts fresh", regardless of the previous situation?

marchbold commented 9 years ago

Hi, Thanks for reporting this. I'll have a look into it. It should be firing an entry event immediately if you are already in the region. Can you let me know what version of iOS you're experiencing this on?

amodo-dev commented 9 years ago

iOS 7. Just to clarify my previous post: On Android, starting monitoring always triggers REGION_ENTER. On iOS, starting monitoring will trigger REGION_ENTER only if REGION_EXIT has been previously triggered. It is not a matter whether I am physically in the region, when I start monitoring, or physically enter it after the monitoring has already started. What seems to be happening is that iOS remembers that you are/were in a certain region, so if you stop and then restart monitoring, before REGION_EXIT was triggered, REGION_ENTER will not trigger. And on iOS REGION_EXIT takes its time. This actually does make sense, as it is logical, but it makes it harder to control the situation.

My question is: Can I somehow "reset the knowledge about regions" on iOS, so that it forgets everything about the region it is in, so that whenever I restart monitoring for a region, it has the same functionality as on Android. When i start monitoring on Android, it has no clue of the past, which is what I consider preferable.

Plozzer commented 9 years ago

Hi all, Same problem for me on iOS, on Android all ok.