Skip to content

Initialization

To use search or other features, TNEntityClient needs to be initialized. These methods will only need to be called once.

Initialization

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import TelenavEntitySDK

/* ... */

let sdkOptions = try! TNEntitySDKOptionsBuilder()
        .apiKey("#API_KEY_PROVIDED_BY_TELENAV#")
        .apiSecret("#API_SECRET_PROVIDED_BY_TELENAV#")
        .cloudEndPoint(cloudEndPoint: "#CLOUD_ENDPOINT_PROVIDED_BY_TELENAV#")
        .locale(Locale.current.languageCode)
        .deviceId("#DEVICE_ID#")  // can be nil
        .userId("#USER_ID#")  // can be nil
        .build()

TNEntityClient.initialize(sdkOptions)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
@import TelenavEntitySDK;

/* ... */

TNEntitySDKOptionsBuilder *builder = [TNEntitySDKOptionsBuilder new];
[builder apiKey:@"#API_KEY_PROVIDED_BY_TELENAV#"];
[builder apiSecret:@"#API_SECRET_PROVIDED_BY_TELENAV#"];
[builder cloudEndPointWithCloudEndPoint:@"#CLOUD_ENDPOINT_PROVIDED_BY_TELENAV#"];
[builder locale:NSLocale.currentLocale.languageCode];
[builder deviceId:@"#DEVICE_ID#"]; // can be nil
[builder userId:@"#USER_ID#"]; // can be nil

NSError *error = nil;
TNEntitySDKOptions *sdkOptions = [builder buildAndReturnError:&error];
if (error != nil) {
    // handle error
} else {
    [TNEntityClient initialize:sdkOptions];
}


The SDK is now ready to use!