SwiftUI Maps & Location: Fundamentals
Mar 15 2022 · Swift 5.5, iOS 15, Xcode 13
Part 2: Core Location
Leave a rating/review
Notes: 20. Conclusion
The student materials have been reviewed and are updated as of January, 2022.
- MapKit Tutorial: Getting Started https://www.raywenderlich.com/7738344-mapkit-tutorial-getting-started
- What’s New in Core Location https://developer.apple.com/videos/play/wwdc2019/705/
- What’s new in location https://developer.apple.com/videos/play/wwdc2020/10660/
- Design for location privacy https://developer.apple.com/videos/play/wwdc2020/10162/
Heads up... You've reached locked video content where the transcript will be shown astext.
At this point, you should have a good idea of how Core Location can benefit you behind the scenes.
Location Manager & CLLocations
When we started this part, you learned about the Location Manager and CLLocations. Remember to follow Apple’s guidelines in accessing Core Location services when you need them. So if you have an app that has a login screen, you don’t want to start tracking location. Rather, have the user login into your app, and then start them when the user does an an action that is location specific.
Permissions & Background Updates
Next you learned about permissions to access Core Location. Remember, while a user gives your app permission today, your app may not have permission tomorrow. When requesting permissions, make sure to provide a clear explanation about why you need permission. If your reason is vague, your app may be stalled in app review. You also saw how Core Location can work in the background. This is a powerful feature, but again, only use it when you need it as it does raises privacy issues.
Then you learned about Geoencoding where you can take an address and convert it into a CLLocation, and of course, do the reverse. This does rely on the network so remember when working geoencoding, your user may not be in ideal network conditions.
Finally, you learned about region monitoring and how to get notifications when a user enters or exits a region. When we first made this series a few years ago, Apple set a hard limit of 20 regions for our app. Since that time, nothing has changed. We can still only track 20 regions, so you’ll need to track only the most important areas.
Where to go from here
As you can see, both MapKit and Core Location provide a great many features to your app. But we’ve only scratched the surface of what is possible. To learn more about MapKit features such as requesting directions, drawing on maps and even creating custom map tiles, check out our Advanced Mapkit Course.