Skip to content

Commit 90c8ae7

Browse files
Guardiola31337zugaldia
authored andcommitted
Support late token initialization (#537)
* support late token initialization * force ci
1 parent 8380d2e commit 90c8ae7

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.mapbox.services.android.telemetry;
2+
3+
4+
import java.lang.annotation.ElementType;
5+
import java.lang.annotation.Retention;
6+
import java.lang.annotation.RetentionPolicy;
7+
import java.lang.annotation.Target;
8+
9+
/**
10+
* An experimental user-facing API. Experimental APIs are quickly evolving
11+
* and might change or be removed in minor versions.
12+
* <p>
13+
* Inspired by org.apache.spark.annotation.Experimental
14+
*/
15+
@Retention(RetentionPolicy.RUNTIME)
16+
@Target( {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER,
17+
ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE, ElementType.PACKAGE})
18+
@interface Experimental {
19+
}

mapbox/libandroid-telemetry/src/main/java/com/mapbox/services/android/telemetry/MapboxTelemetry.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,4 +660,23 @@ private void shutdownTelemetry() {
660660
timer = null;
661661
}
662662
}
663+
664+
/**
665+
* Set the access token, for internal use only.
666+
* <p>
667+
* This is an experimental API. Experimental APIs are quickly evolving and
668+
* might change or be removed in minor versions.
669+
*
670+
* @param accessToken the new access token
671+
*/
672+
@Experimental
673+
public void setAccessToken(@NonNull String accessToken) {
674+
if (client == null || TextUtils.isEmpty(accessToken)) {
675+
throw new TelemetryException(
676+
"Please, make sure you have initialized MapboxTelemetry before resetting the access token and it's a valid one."
677+
+ " For more information, please visit https://www.mapbox.com/android-sdk.");
678+
}
679+
this.accessToken = accessToken;
680+
client.setAccessToken(accessToken);
681+
}
663682
}

0 commit comments

Comments
 (0)