Article

Getting the User's Location

Learn how to receive location data in your app.

Overview

Core Location offers three different services for fetching the user's location. Each service offers different benefits and comes with different power and authorization requirements. You can use a single service or you can use multiple services at different times, depending on your needs.

Table 1

Location services

Service

Description

Visits location service

The most power-efficient way to gather location data. This service delivers location updates when the user has spent time in one location and then moves on. Each update includes both the location and the amount of time spent at that location.

This service is not intended for navigation or other real-time activities. Instead, use it to identify patterns in the user's behavior and apply that knowledge to other parts of your app. For example, a music app might prepare a workout playlist when the user leaves the house and heads to the gym.

This service requires Always authorization.

Significant-change location service

A power-friendly alternative for apps that need to track the user's location but do not need frequent updates or the precision offered by GPS. This service relies on lower-power alternatives to determine the user's location and delivers updates only when significant changes to that location occur.

You might use this service to deliver suggestions for nearby points of interest when the user is walking.

This service requires Always authorization.

Standard location service

A configurable, general-purpose solution for getting the user's location in real time. This service uses significantly more power than the other location services, but it delivers the most accurate and immediate location information.

Use this service only when you really need it, such as when offering navigation instructions or when recording a user's path on a hike.

This service requires either In-Use or Always authorization.

Always choose the most power-efficient service that serves the needs of your app. To help save power, disable location services (or switch to a lower-power alternative) when you do not need the location data offered by the service. For example, you might disable location services when your app is in the background and would not use that data otherwise.

Topics

Related Topics

Using the Visits Location Service

Get location updates in the most power-efficient way, but less frequently than with other services.

Using the Significant-Change Location Service

Get location updates in a power-friendly way, but less frequently than with the standard location service.

Using the Standard Location Service

Get regular location updates based on the parameters you specify.

Handling Location Events in the Background

Take advantage of background execution modes to respond to location-related events at any time.

See Also

Location Updates

class CLLocation

The latitude, longitude, and course information reported by the system.

struct CLLocationCoordinate2D

The latitude and longitude associated with a location, specified using the WGS 84 reference frame.

class CLFloor

The floor of a building on which the user's device is located.

class CLVisit

Information about the user's location during a specific period of time.