New in SwiftUI and iOS 15: LocationButton
User’s location is probably the most sought out permission after notifications but its also the most sensitive piece of information. Over the years, Apple has invested lots of time to make sure that user’s information is not shared without their knowledge.
This also mean that when apps need user’s location permission they have to jump though many hoops to make it possible. While it is worth investing time when app relies on location for the most part like map based apps, but what about apps who need location permission just once:
- Maybe you are digitally signing a form and for legal reasons, your app wants to capture location of user where form was signed
- Or getting your location once so you can share it with your friend, you are meeting in a park or concert.
For all these one time scenarios, Apple introduced LocationButton in iOS 15 for both SwiftUI and UIKit. We will talk about SwiftUI’s LocationButton in this article.
LocationButton makes it easy to request one-time location authorization. When user taps on the button, app requests one-time temporary access to user’s location data. User is presented with permission dialog like below:
CoreLocation framework is still responsible for managing location related information including querying the…