3. Specify Location Permissions

The Versus SDK needs the user's location in order to show eligible challenges in their area. For example, some challenges are created specifically to target the United States, while others may apply to the United States and Canada.

No special setup is needed for location services to work in the Unity Editor or on an iOS device.

Android Setup

Android requires location permissions to be specified in the AndroidManifest.xml.

Here is an example:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.unity3d.player"
    xmlns:tools="http://schemas.android.com/tools"
    android:installLocation="preferExternal">
    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"
        android:anyDensity="true"/>
​
    <application
        android:theme="@style/UnityThemeSelector"
        android:icon="@mipmap/app_icon"
        android:label="@string/app_name">
        <activity android:name="com.unity3d.player.UnityPlayerActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
        </activity>
    </application>
​
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <meta-data
        android:name="unityplayer.SkipPermissionDialog"
        android:value="true"
        />
​
</manifest>

The important line in the file is: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />.

This file must be included in Assets > Plugins > Android

Skip Permissions Dialog Placement on Android

The location prompt placement is customizable for Android users.
On install, the Android user will be shown the location permissions prompt. To change this, open up the AndroidManifest.xml and update to be enclosed within the tags.

<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name">
     <intent-filter>
         <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.LAUNCHER" />
     </intent-filter>
     <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
     <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />
</activity>

This will prevent users on devices with Android 6.0/API Level 23 & above from being prompted for location permissions on install.
Users on devices below Android 6.0/API Level 23 will receive the location permissions prompt on install.

You can view where the location permissions prompt is triggered in the Sign Up Flow contained in the User Flows Section.

Add Location Usage Description

Be sure to add a Location Usage Description within Unity to avoid issues with location flows. You can do so by navigating within Unity to Build Settings > Player Settings > Other Settings. It should be in the Identification section.

📘

Troubleshooting

Note: when testing with the Unity Editor, there will be no prompt to enable location services. Instead, the Versus SDK behaves as if the user is located in the United States.

If challenges can be seen in the Unity Editor, but not on the device, there may be a chance that your location is being barred.
This may be resolved by spoofing your location or perhaps something Versus can update in our system. Feel free to contact us for support in case this occurs.