Skip to content

JSON Configuration

Starting with the version of SDK 8.0.0 you now have full power to configure multiple aspects of SDK.

This document describes how to include JSON configuration file in your project.

Minimal required configuration can be found here Minimal JSON Configuration

For full description of JSON Configuration follow Full JSON Configuration and JSON Schema Documentation for documentation.

iOS

Configuration JSON is an optional file you can place into your app. You need at least the Authentication and License keys for a proper initialization, but you can do much more. If you want to add more configuration items, you can simply build the JSON and pass its content as NSDictionary to the configuration argument of the SYContextInitRequest object:

do {
    if let configData = try String.init(contentsOfFile: Bundle.main.path(forResource: "your_config_file", ofType: "json")!).data(using: .utf8) {
        let dict:[AnyHashable: Any] = try JSONSerialization.jsonObject(with: configData, options: .mutableContainers) as! [AnyHashable: Any]
        let initRequest = SYContextInitRequest(configuration: dict)
        SYContext.initWithRequest(initRequest) { (result, description) in

        }
    }
} catch {

    // catch errors

}
NSData *configData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"settings_app" ofType:@"json"]];
NSError* error = nil;
NSMutableDictionary *dict = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingMutableContainers error:&error];

SYContextInitRequest* initRequest = [[SYContextInitRequest alloc] initWithConfiguration:dict];

if(error) {
    // your error handling code
    NSLog(@"%@", [error localizedDescription]);
}

[SYContext initWithRequest:initRequest completion:^(SYContextInitResult result, NSString * _Nonnull description) {
    // your init completion code
}];

Android

By using the JSON configuration you can further expand the customization of our SDK. A "stringified" configuration (jsonConfig) is necessary for proper initialization of the SDK. You can either pass it as a string, or use the SygicEngine.JsonConfigBuilder.

Example of how to use the JsonConfigBuilder

val config = SygicEngine.JsonConfigBuilder()
config.mapReaderSettings().startupOnlineMapsEnabled(true)
val path = applicationContext.getExternalFilesDir(null).toString()
config.storageFolders().rootPath(path)
val clientID = "your_client_id"
config.authentication(clientID)
val licenseKey = "your_license_key"
config.license(license_key)

SygicEngine.initialize(
            this,
            null,
            null, config.build(),
            ...

The .build() method parses the config object into a string.

If you would like to build the JSON yourself and pass it directly as a string, it has to have a proper JSON structure, for example:

{
    "Authentication": {
        "app_key": "<your app key>"
    },
    "License": {
        "license_key": "<your license key>"
    }
}