Enable the Geospatial API for your Unity (AR Foundation) app targeting iOS

Configure your app's settings so that it can use the Geospatial API.

Prerequisites

Make sure that you understand fundamental AR concepts and how to configure an ARCore session before proceeding.

See the Introduction to the Geospatial API for more information about the Geospatial API.

If you're new to developing with ARCore, see Getting started for information about software and hardware requirements, prerequisities and other information specific to the platforms you are using.

To use the ARCore Geospatial API, your project must support AR Foundation and the ARCore Extensions for AR Foundation.

Enable the ARCore API

Before using the Visual Positioning System (VPS) in your app, you must first enable the ARCore API in a new or existing Google Cloud project. This service is responsible for hosting, storing, and resolving Geospatial anchors.

Keyless authorization is preferred, but API Key authorization is also supported.

Add required libraries to your app

After authorizing your app to call the ARCore API, you must add libraries to enable Geospatial features in your app.

  1. Navigate to Edit > Project Settings > XR Plug-In Management > ARCore Extensions. Make sure that iOS Support Enabled is selected.
  2. Under Optional Features, select Geospatial.

Enable Geospatial capabilities in the session configuration

Once Geospatial functionality has been enabled in your app, enable Geospatial capabilities in your app’s AR session configuration so that it can communicate with the ARCore API:

  1. Ensure that the project Assets folder contains an ARCoreExtensionsConfig scriptable object. To create one, right-click in the Assets pane and select Create > XR > ARCore Extensions Config.
  2. Select the ARCoreExtensionsConfig scriptable object in your Assets folder and set the Geospatial Mode to Enabled.

  3. Configure the ARCore Extensions game object to use the ARCoreExtensionsConfig configuration. In the Hierarchy pane, locate the ARCore Extensions game object you created when you initially set up ARCore Extensions, and connect the ARCore Extensions Config field to the ARCoreExtensionsConfig scriptable object in your Assets folder.

Prompt user to allow usage of device data

Apps that use the ARCore Geospatial API must present the user with a prompt to acknowledge and allow the use of data from their device. See User privacy requirements for more information.

Check device compatibility

Not all devices that support ARCore also support the Geospatial API. To check the user's device for compatibility, call AREarthManager.IsGeospatialModeSupported(). If this returns FeatureSupported.Unsupported do not attempt to configure the session.

Ask user for location permissions at runtime

To enable Unity's location services in a script that triggers the runtime permission requests, do the following:

  1. In Project Settings > iOS > Other Settings > Location Usage Description, enter the name of the app that is requesting permissions.

  2. Enable Unity's location services to trigger the runtime permission request, as follows:

    public void OnEnable()
    {
        Input.location.Start();
    }
    
    public void OnDisable()
    {
        Input.location.Stop();
    }
    

    See Unity's LocationService documentation for more information.

Check Geospatial availability at the device's current location

Because the Geospatial API uses a combination of VPS and GPS to determine a Geospatial pose, the API can be used as long as the device is able to determine its location. In areas with low GPS accuracy, such as indoor spaces and dense urban environments, the API will rely on VPS coverage to generate high accuracy poses. Under typical conditions, VPS can be expected to provide positional accuracy of approximately 5 meters, and rotational accuracy of 5 degrees. Use AREarthManager.CheckVpsAvailability() to determine if a given location has VPS coverage.

The Geospatial API can also be used in areas that do not have VPS coverage. In outdoor environments with few or no overhead obstructions, GPS may be sufficient to generate a pose with high accuracy.

What's next