...
Create an instance of
NMApiCredentials
with mandatory parameters (account ID, password, email ID, service ID) with one of the methods provided.Call the
+ (void)obtainApiKeyWithCredentials:apiKeyType:completion:
method, to request a new API Key. A result is expected to come in the completion block. A requested To request a default key, useNMApiKeyTypeDefault
API Key Type. Additionally, for a dedicated tile service, aNMApiKeyTypeTiles
API Key Type should can be specifiedprovided.Check received API Key and
NSError
object. Non-empty error instance indicates a failed request. A type of received error. It’s error code corresponds an error type, specified inNMApiKeyObtainError
.
...
Code Block | ||
---|---|---|
| ||
NMApiCredentials *credentials = [NMApiCredentials alloc] initWithAccountId:@"yourAccountIdaccountId" emailId:@"yourEmailyour@email.com" password:@"yourPAsswordpassword" serviceId:@(1234123); [NMSdk obtainApiKeyWithCredentials:credentials apiKeyType:NMApiKeyTypeDefault completion:^(NSString * _Nullable apiKey, NSError * _Nullable error) { // if (error) { // Handle error // } // if (apiKey && [apiKey lenght] > 0) { // Store the received API key securely // Now you can start the SDK // [navmiiSDK startWithSettings:configurationSettings completion:nil]; // } // Next time pass the key to the SDK via NMConfigurationSettings object // NMConfigurationSettings *configurationSettings = [NMConfigurationSettings new]; // configurationSettings.apiKey = apiKey; // [navmiiSDK startWithSettings:configurationSettings completion:nil]; }]; }); |
...
Code Block | ||
---|---|---|
| ||
func setupSdk() async { do { let apiKey = try await requestApiKey() // Store the received API key securely try await startSDK(with: apiKey) } catch { // Handle error print(error) } } func requestApiKey() async throws -> String { let credentials = NMApiCredentials(accountId: "12345678accountId", emailId: "your@email.com", password: "Passwordpassword", serviceId: 123456) return try await NMSdk.obtainApiKey(withCredentials: credentials, apiKeyType: .default) } func startSDK(with apiKey: String) async throws { let settings = NMConfigurationSettings() settings.apiKey = apiKey return try await sdk.start(withSettings: settings) } |
...
Code Block | ||
---|---|---|
| ||
func requestApiKey() async throws -> String {
let credentials = NMApiCredentials(accountId: "12345678",
emailId: "your@email.com",
password: "Password",
serviceId: 123)
return try await NMSdk.obtainApiKey(withCredentials: credentials, apiKeyType: .tiles)
} |
...