Other
Get User Identifier
By adding a "User Identifier", you can search for specific users' performance issues in the Tingyun reporting platform using this identifier.
- Related API
/**
* Set user identifier, cannot exceed 256 characters, can be called multiple times at any location (value override)
* @userId: Information that uniquely identifies a user
*/
+ (void)setUserIdentifier:(NSString *)userId;
- Code Example
- (void)viewDidLoad
{
[super viewDidLoad];
// User identifier can be email, phone number, or other information that can identify user identity, such as xxx@tingyun.com
[NBSAppAgent setUserIdentifier:@"userId"];
}
First Launch Module Feature Switch
For compatibility reasons, on first launch the SDK only enables all feature modules in debug mode, and only enables crash module in non-debug mode. You can enable SDK module switches through the following API.
- Related API
/**
* SDK first initialization has not yet interacted with Tingyun platform, default module switches only enable "Crash Module". You can enable "Network Module" and "User Experience Module" to collect application first launch data.
* @warning: Calling this API to set startup options, SDK first launch is not controlled by Tingyun platform switches
*/
+ (void)setStartOption:(NBSOPTION)option;
- Code Example
// Call before SDK initialization, first launch enables network, crash collection functionality, user experience analysis.
[NBSAppAgent setStartOption:NBSOption_Net|NBSOption_UI|NBSOption_Crash];
[NBSAppAgent startWithAppID:@"Your_appkey"];
Custom App Version Number
SDK by default uses the application's "CFBundleShortVersionString" as the version number for upload. If you need to customize the version number, you can call this API before initializing the SDK for configuration.
- Related API
/**
* @brief Set custom App version number, maximum 64 characters, supports Chinese, English, numbers, underscores
*/
+ (void)setVersionName:(NSString *)versionName;
- Code Example
int main(int argc, char * argv[]) {
@autoreleasepool {
[NBSAppAgent setVersionName:@"1.0.0"];
[NBSAppAgent startWithAppID:@"appkey" location:YES];
...
}
}
Get Tingyun Device ID
When the application first launches, the Tingyun server will deliver a deviceId to identify the device. Users can get the Tingyun deviceId value through the API.
- Related API
/**
* @return Returns the device id generated by Tingyun platform, this id is returned by the server, may be empty on first retrieval
*/
+ (NSString *)getTingyunDeviceId;
- Code Example
- (void)getTyDeviceId
{
NSString *tyDid = [NBSAppAgent getTingyunDeviceId];
...
}
Set Geographic Location Information
You can call the API to set latitude and longitude to accurately obtain device geographic location information.
- Related API
/**
* @brief Set latitude and longitude.
*/
+ (void)setLatitude:(double)latitude longitude:(double)longitude;
- Code Example
- (void)doSomething
{
...
[NBSAppAgent setLatitude:latitude longitude:longitude];
...
}
Compliance Configuration
Given "Privacy Security" requirements that third-party SDKs need to initialize after user consent to "Privacy Permissions", you can control the SDK's data transmission behavior through the "Compliance Configuration" API. Only effective on first installation launch.
- Related API
/**
* @brief Notify SDK whether the user has agreed to the privacy agreement. Should ensure this API is called at least once on each startup
* @param agreement YES indicates user has agreed to privacy agreement
* @discussion
This API needs to be used with "+startWithAppID:launchImmediately:"; After application installation first launch, when launchImmediately: is set to NO, before agreement is set to YES, SDK only collects data and does not initiate data upload requests; After agreement is set to YES, SDK will initiate data upload requests and upload data collected before agreement was set to YES
* @warning Clearing data in sandbox Library/Cache/NBSCache directory will cause this functionality to malfunction, please be careful
*/
+ (void)setUserPrivacyAgreement:(BOOL)agreement;
- Code Example
int main(int argc, char * argv[]) {
NSString * appDelegateClassName;
@autoreleasepool {
[NBSAppAgent startWithAppID:@"APPKey" launchImmediately:NO];
appDelegateClassName = NSStringFromClass([AppDelegate class]);
}
return UIApplicationMain(argc, argv, nil, appDelegateClassName);
}
- (void)getConsumerAgreement
{
...
if(agreement)
{
[NBSAppAgent setUserPrivacyAgreement:YES];
}
...
}
Get SDK Version Number
Get current SDK version.
- Related API
/**
* @brief Get SDK version number
*/
+ (NSString *)agentVersion;
- Code Example
NSString *sdkVesion = [NBSAppAgent agentVersion];
Enable SDK Log
After calling the API, SDK INFO logs can be printed.
- Related API
/**
* @brief Whether to enable instrumentation console logs, default is disabled.
*/
+ (void)setLogEnable:(BOOL)enale;
- Code Example
[NBSAppAgent setLogEnable:YES];
[NBSAppAgent startWithAppID:@"Your_appkey"];
Set Business Line Name
Using the "Set Business Line" API can distinguish crashes, freezes, and network errors by business line to view performance data for specific businesses.
- Related API
/**
* @brief Set current business, same key values will override, keeping the latest value
* @params businessLine Business name, maximum length 256 bytes
* @params key Fixed as bname
*/
+ (void)setBusinessLine:(NSString *)businessLine forKey:(NSString *)key;
- Code Example
- (void)shoppingCar
{
[NBSAppAgent setBusinessLine:@"Shopping Cart" forKey:@"bname"];
}