问题
How to detect if GPS is available?
The iPod touch and iPad WiFi version don't have GPS, they have something else based on WiFi. Anyway, how to know if GPS is available? Or how to detect iPod Touch or iPad Wifi model?
回答1:
This is a common difficulty on iOS... One way would be to get a location and check if the altitude is present.
- if a valid altitude is present, the position has most probably been computed using GPS
- else either the GPS has not picked-up any signal yet or it is not present.
Anyway on iOS Apple has a single interface for all location providers because they intend the developers to express their requirements in terms of accuracy, the control of the technology used should be left to the OS.
回答2:
Not sure yet if my solution will cover every device... but... What I do is if it's an iPad ask if the device has a cellular connection (Know if iOS device has cellular data capabilities). If so, it will most likely also have GPS. Not sure if this will cover every device correctly, but at least my test-devices are detected correctly.
回答3:
To be 100% sure that it is a GPS loaction, check for attribute course. if this is valid then its from GPS. but when not moving course is invalid too.
you can use that condition as initial trigger that now you have GPS.
If you need an initial valid GPS when not moving, check for vertical accuracy < 100 and horicontal < 50m
来源:https://stackoverflow.com/questions/14665773/detect-if-device-has-gps