We want to alert users of our Android app when another user of the same app is in close physical proximity, much like how Covid warning apps were able to alert individuals of affected users in their physical proximity. I'm aware that such apps depended on BLE (Bluetooth Low Energy) to achieve this functionality, however, the documentation on BLE has been very confusing and does not provide any guides as to how to achieve this. What we want to do is have an instant notification pop up when another user is in proximity, and as such the app must function (I assume) as both an advertiser as well as a scanner? Furthermore since this functionality would need to take place constantly, I'm not sure if we would need to use a foreground service or if there needs to be another approach to this. I've read up on GATT servers but haven't been able to find any examples or implementations that fix the problem of doing both the scanning and advertising at the same time. Would appreciate any help to nudge me in the right direction.
Apple and Google wrote a Bluetooth specification about how Exposure Notification works.
Due to the power constraints of mobile devices, it is always tricky to get this to work in the background on mobile devices. Therfore Exposure Notification API is part of the OS, but only usable by Public Health Agencies.
With this knowledge, you should be able to build a similar, perhaps not quite as reliable system. At least many BLE Beacon Apps do.
There is a lot of information available on this task:
Bluetooth Low Energy Advertising
David Young wrote a nice Blog posts about this topic.