Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 1.67 KB

README.md

File metadata and controls

38 lines (26 loc) · 1.67 KB

Map Widget Example 🗺

Example application showing how to display a map with the current user-location inside a widget.

Widget

Note: As a UIViewRepresentable is not supported in widgets, Apple's recommendation for displaying maps inside widgets is to use a MKMapSnapshotter.

How to use

📲 Clone the repository and run pod install in the terminal to install the dependencies. Afterwards run the example application, allow access to location data and add the widget named MapWidgetExample to your home screen.

Widget

🧪 All code for the widget lives inside the folder MapWidget. The corresponding application code inside the folder MapWidgetExample does not contain any logic other than requesting access to location data.

Requesting Authorization for Location Services

🔐 To receive the current user-location you have to add the following lines to the Info.plist of your application.

Privacy - Location When In Use Usage Description
Privacy - Location Usage Description

Furthermore you have to add these three lines to the Info.plist of your widget extension as well.

Privacy - Location When In Use Usage Description
Privacy - Location Usage Description
Widget Wants Location

Note: This is already done in this example application.

Links