googlesamples / ios-nearby

69 stars 30 forks source link

NearbyMessages finds messages from lost BLE devices #17

Closed pNre closed 2 years ago

pNre commented 7 years ago

Hi, I've been noticing an odd behavior during my test of the NearbyMessages library. Here are the steps I've been following:

What I expect here is for subscriptionWithMessageFoundHandler to not be called again if the beacon is no longer in range. The same thing happens using the sample app from this repo.

Do you have any advice? Thanks

dan-webb commented 7 years ago

Hello,

I've reproduced what you're seeing, and it's a bug. I'm working on a fix, and it will ship with the next release.

A possible workaround: When your app is backgrounded, deallocate the GNSMessageManager; when it is foregrounded, re-create it. The stale beacon state is store in this object, so creating a new one will start fresh. (Use the UIApplicationDidEnterBackgroundNotification and UIApplicationWillEnterForegroundNotification notifications.)

Thanks for the bug report, and apologies for the hassle!