Silent Mode Related Interfaces
Permanent Silent Mode
By invoking the
disable
interface, the SDK can be put into a silent mode, where it will stop collecting data and cease communication with the server until theenable
interface is called to exit silent mode. Use this feature with caution according to actual circumstances. Note: The silent mode is cached locally, and the SDK will remain in silent mode after the app is restarted.
- Related Interface
/**
* Disable the SDK. The next launch will take effect immediately, and the upload will be disabled.
*/
+ (void)disable;
- Code Example
- (void)doSomething
{
...
[NBSAppAgent disable];
...
}
Temporary Silent Mode
By invoking this interface, the SDK can be put into a temporary silent mode, where it will stop collecting data and cease communication with the server within the set time frame. The unit can be set to hours, minutes, and seconds, and the maximum silent duration is 30 days. After the silent duration, the SDK will restart with cached configurations to start each module. Note: If the app is in silent mode when launched and reaches the silent duration during runtime, the SDK will remain in silent mode until the app is restarted.
- Related Interface
/**
* @brief Disable the SDK for a limited time.
* @param unit The unit of time.
* @param duration The length of time.
*/
+ (void)disableTimeUnit:(NBSTimeUnit)unit duration:(NSInteger)duration;
- Code Example
- (void)doSomething
{
...
[NBSAppAgent disableTimeUnit:NBSTimeUnitHour duration:2];
...
}
Cancel Silent Mode
By invoking this interface, the SDK can be taken out of silent mode. This interface must be called after invoking the silent mode interface to activate the SDK, and the SDK will start each module according to the cached configurations upon the next launch.
- Related Interface
/**
* Enable the SDK. The next launch will take effect.
*/
+ (void)enable;
- Code Example
- (void)doSomething
{
...
[NBSAppAgent enable];
...
}