Skip to content

Monitoramento de localização

Saiba como rastrear o local por meio do Braze SDK.

Logging the current location

Even if continuous tracking is disabled, you can manually log the user’s current location using the setLastKnownLocation() method.

1
2
3
4
5
6
Braze.getInstance(context).getCurrentUser(new IValueCallback<BrazeUser>() {
  @Override
  public void onSuccess(BrazeUser brazeUser) {
    brazeUser.setLastKnownLocation(LATITUDE_DOUBLE_VALUE, LONGITUDE_DOUBLE_VALUE, ALTITUDE_DOUBLE_VALUE, ACCURACY_DOUBLE_VALUE);
  }
}
1
2
3
Braze.getInstance(context).getCurrentUser { brazeUser ->
  brazeUser.setLastKnownLocation(LATITUDE_DOUBLE_VALUE, LONGITUDE_DOUBLE_VALUE, ALTITUDE_DOUBLE_VALUE, ACCURACY_DOUBLE_VALUE)
}

Continuously tracking the location

To continuously track a user’s location, you’ll need to declare your app’s intent to collect location data by adding at least one of the following permissions to your AndroidManifest.xml file.

Your AndroidManifest.xml should be similar to the following:

1
2
3
4
5
6
7
8
<manifest ... >
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application ... >
        ...
    </application>
</manifest>

Disabling continuous tracking

You can disable continuous tracking at compile time or runtime.

To disable continuous location tracking at compile time, set com_braze_enable_location_collection to false in braze.xml:

1
<bool name="com_braze_enable_location_collection">false</bool>

To selectively disable continuous location tracking at runtime, use BrazeConfig:

1
2
3
4
BrazeConfig brazeConfig = new BrazeConfig.Builder()
  .setIsLocationCollectionEnabled(false)
  .build();
Braze.configure(this, brazeConfig);
1
2
3
4
val brazeConfig = BrazeConfig.Builder()
    .setIsLocationCollectionEnabled(false)
    .build()
Braze.configure(this, brazeConfig)

guide/swift/analytics/tracking_location.md developer_ %}

guide/web/analytics/tracking_location.md developer_ %}

QUÃO ÚTIL FOI ESTA PÁGINA?
New Stuff!