Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD react-native-hms-map setAccessToken function and made apiKey optional #338

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1411,13 +1411,18 @@ public String getName() {
}

@ReactMethod
public void initializer(final String apiKey, final String routePolicy, final Promise promise) {
public void initializer(final String apiKey, final String routePolicy, final String accessToken, final Promise promise) {
if (routePolicy != null && !routePolicy.isEmpty()) {
MapsInitializer.initialize(context, routePolicy);
} else {
MapsInitializer.initialize(context);
}
MapsInitializer.setApiKey(apiKey);
if (accessToken != null && !accessToken.isEmpty()) {
MapsInitializer.setAccessToken(accessToken);
}
if (apiKey != null && !apiKey.isEmpty()) {
MapsInitializer.setApiKey(apiKey);
}
promise.resolve(null);
}

Expand Down
13 changes: 10 additions & 3 deletions react-native-hms-map/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1619,9 +1619,16 @@ declare module "@hmscore/react-native-hms-map" {

/**
* Initializes the Map SDK. You can set the data routing location. The options for routePolicy are CN (China), DE (Germany), SG (Singapore), and RU (Russia).
* Sets the access token of the Map SDK.
*/
initializer(apiKey: String, routePolicy: String): Promise<void>;
* Sets the apiKey or accessToken of the Map SDK.
* apiKey does not need to be specified if the api_key field in the agconnect-services.json file already specifies an API key.
* If its set its takes precedence.
* If accessToken and apiKey set both, accessToken will be used for authentication
*/
initializer(
apiKey?: String,
routePolicy?: "CN" | "DE" | "SG" | "RU",
accessToken?: String
): Promise<void>;

/**
* Obtains all attributes of the Huawei map object
Expand Down