getAppBaseInfo
Overview
getAppBaseInfo retrieves the base information of the current application, including the SDK version, debug switch, language, app version, theme, font size scale factor, and font size setting.
This interface is synchronous; after being called it directly returns an NSDictionary containing the app base information.
Method Declaration
objectivec
/**
Retrieves the base information of the current application.
@return A dictionary containing app base information such as app version, host, etc.
*/
- (NSDictionary *)getAppBaseInfo;Parameters
This method takes no parameters.
Return Value
| Return Type | Description |
|---|---|
NSDictionary * | The app base information dictionary. |
The returned dictionary contains the following fields:
| Field | Type | Description |
|---|---|---|
SDKVersion | NSString * | The current SDK version number. |
enableDebug | NSNumber * / BOOL | Whether Debug mode is enabled. YES means enabled, NO means disabled. |
language | NSString * | The language identifier used by the current app or SDK. |
version | NSString * | The current app version number. |
theme | NSString * | The current theme configuration, such as light, dark, or a custom theme. |
fontSizeScaleFactor | NSNumber * | The font size scale factor. |
fontSizeSetting | NSString * / NSNumber * | The font size setting; the actual type and value depend on what the SDK returns. |
Example
Retrieve app base information
objectivec
NSDictionary *appBaseInfo = [self getAppBaseInfo];
NSLog(@"App Base Info: %@", appBaseInfo);Read returned fields
objectivec
NSDictionary *appBaseInfo = [self getAppBaseInfo];
NSString *SDKVersion = appBaseInfo[@"SDKVersion"];
NSNumber *enableDebug = appBaseInfo[@"enableDebug"];
NSString *language = appBaseInfo[@"language"];
NSString *version = appBaseInfo[@"version"];
NSString *theme = appBaseInfo[@"theme"];
NSNumber *fontSizeScaleFactor = appBaseInfo[@"fontSizeScaleFactor"];
id fontSizeSetting = appBaseInfo[@"fontSizeSetting"];
NSLog(@"SDKVersion: %@", SDKVersion);
NSLog(@"enableDebug: %@", enableDebug);
NSLog(@"language: %@", language);
NSLog(@"version: %@", version);
NSLog(@"theme: %@", theme);
NSLog(@"fontSizeScaleFactor: %@", fontSizeScaleFactor);
NSLog(@"fontSizeSetting: %@", fontSizeSetting);Safely read fields
objectivec
NSDictionary *appBaseInfo = [self getAppBaseInfo];
NSString *SDKVersion = nil;
id SDKVersionValue = appBaseInfo[@"SDKVersion"];
if ([SDKVersionValue isKindOfClass:[NSString class]]) {
SDKVersion = SDKVersionValue;
}
BOOL enableDebug = NO;
id enableDebugValue = appBaseInfo[@"enableDebug"];
if ([enableDebugValue respondsToSelector:@selector(boolValue)]) {
enableDebug = [enableDebugValue boolValue];
}
NSString *language = nil;
id languageValue = appBaseInfo[@"language"];
if ([languageValue isKindOfClass:[NSString class]]) {
language = languageValue;
}
NSString *version = nil;
id versionValue = appBaseInfo[@"version"];
if ([versionValue isKindOfClass:[NSString class]]) {
version = versionValue;
}
NSString *theme = nil;
id themeValue = appBaseInfo[@"theme"];
if ([themeValue isKindOfClass:[NSString class]]) {
theme = themeValue;
}
CGFloat fontSizeScaleFactor = 1.0;
id fontSizeScaleFactorValue = appBaseInfo[@"fontSizeScaleFactor"];
if ([fontSizeScaleFactorValue respondsToSelector:@selector(floatValue)]) {
fontSizeScaleFactor = [fontSizeScaleFactorValue floatValue];
}
id fontSizeSetting = appBaseInfo[@"fontSizeSetting"];
NSLog(@"SDKVersion: %@", SDKVersion);
NSLog(@"enableDebug: %@", @(enableDebug));
NSLog(@"language: %@", language);
NSLog(@"version: %@", version);
NSLog(@"theme: %@", theme);
NSLog(@"fontSizeScaleFactor: %@", @(fontSizeScaleFactor));
NSLog(@"fontSizeSetting: %@", fontSizeSetting);Return Data Example
The following example is only for illustrating the field structure; the actual values depend on what the SDK returns.
objectivec
{
SDKVersion = "1.0.0";
enableDebug = 1;
language = "zh-Hans";
version = "1.2.3";
theme = "light";
fontSizeScaleFactor = "1.0";
fontSizeSetting = "normal";
}Or in JSON representation:
json
{
"SDKVersion": "1.0.0",
"enableDebug": true,
"language": "zh-Hans",
"version": "1.2.3",
"theme": "light",
"fontSizeScaleFactor": 1.0,
"fontSizeSetting": "normal"
}Notes
- This interface takes no parameters.
- This interface is synchronous; it returns the result directly after being called.
- The returned fields include
SDKVersion,enableDebug,language,version,theme,fontSizeScaleFactor, andfontSizeSetting. - It is recommended to perform type checks when reading fields, to avoid exceptions caused by fields being empty or having an unexpected type.
- The field value types depend on what the SDK actually returns.
