Add at least one of the following the following permission to your
AndroidManifest.xml file to declare your app’s intent to collect location data:
1 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
1 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
With the release of Android M, Android switched from an install-time to a runtime permissions model. To enable location tracking on devices running M and above, the app must explicitly receive permission to use location from the user (Braze will not do this). Once location permissions are obtained, Braze will automatically begin tracking location on the next session start. Devices running earlier versions of Android only require location permissions to be declared in the
AndroidManifest.xml. For more information, visit Android’s permission documentation.
ACCESS_FINE_LOCATION includes GPS data in reporting user location while
ACCESS_COARSE_LOCATION includes data from the most battery-efficient non-GPS provider available (e.g. the network). Coarse location location will likely be sufficient for the majority of location data use-cases; however, under the runtime permissions model, receiving location permission from the user implicitly authorizes the collection of fine location data. You can read more about the differences between these location permissions and how you ought to utilize them here.
Disabling Automatic Location Tracking
To disable automatic location tracking, set
com_appboy_disable_location_collection to true in
1 <bool name="com_appboy_disable_location_collection">true</bool>
Then you can manually log single location data points via the setLastKnownLocation() method on
AppboyUser like this:
1 Appboy.getInstance(YOUR_ACTIVITY.this).getCurrentUser().setLastKnownLocation(LATITUDE_DOUBLE_VALUE, LONGITUDE_DOUBLE_VALUE, ALTITUDE_DOUBLE_VALUE, ACCURACY_DOUBLE_VALUE);