From the documentation, it's not clear to me if apps have permission to see either other nearby SSIDs or the names of other networks that the device has previously connected to.
If the app has access to either one of those, it's equivalent to being given location data.
Furthermore, last I checked, both iOS and Android broadcast the list of previously-connected SSIDs to nearby routers when connecting. That enables companies which track people's physical location over time without them having to download an app (yes, these companies exist[0]).
As the sibling commenter said, you typically can access connected BSSID's which are essentially unique.
However, to answer your question, on iOS there is no API for accessing nearby not-connected wifi, and on Android it exists but I believe it requires location permission.
> Whoa.. why do random routers need my SSID location history? Is that list removable by “forgetting” all the previous networks?
It's how the standard currently works and what enables fast reconnection. IIRC, the device sends out all available SSIDs, at the router responds with the one(s) it's able to use to connect.
I agree that this is backwards, and I'd rather have slightly slower WiFi reconnection in exchange for better privacy. I don't know what the OS-level behavior is if you delete all previous networks. I assume it works, but I haven't tested it.
Oh, and for what it's worth, this isn't just for mobile devices. Your laptop probably does it too. In fact, OS X has an annoying habit of connecting to WiFi networks in the background even when the laptop is closed and asleep, which means it's doing this broadcasting behavior as long as the WiFi setting is turned on.
The BSSID can be read too, so I don't think it's worth trying to figure out ways to add some obscurity to the SSID (no matter what downsides would come with that).