AMAAppMetricaCrashes class
- Instance methods
- Method descriptions
- +crashes:
- -setConfiguration:
- -reportNSError:onFailure:
- -reportNSError:options:onFailure:
- -reportError:onFailure:
- -reportError:options:onFailure:
- -setErrorEnvironmentValue:forKey:
- -clearErrorEnvironment:
- -requestCrashReportingStateWithCompletionQueue:completionBlock:
- -enableANRMonitoring:
- -enableANRMonitoringWithWatchdogInterval:pingInterval:
- -reporterForAPIKey:
- -pluginExtension:
This class provides functions for sending error and crash messages for AppMetrica integration.
Instance methods
Accesses the |
|
Configures the error messaging mechanism for the app. |
|
Sends an |
|
Sends an |
|
Sends a message about an error matching the |
|
Sends a message about an error matching the |
|
Sets the key-value pair that will be associated with errors and crashes. |
|
Deletes all key-value pairs associated with errors and crashes. |
|
-requestCrashReportingStateWithCompletionQueue:completionBlock: |
Requests the current crash status. |
Enables ANR monitoring with default parameters. |
|
Enables ANR monitoring with custom parameters. |
|
Returns an |
|
Creates an |
Method descriptions
+crashes:
+ (instancetype)crashes (crashes())
Accesses the AMAAppMetricaCrashes
singleton.
Returns:
The AMAAppMetricaCrashes
singleton.
-setConfiguration:
- (void)setConfiguration:(AMAAppMetricaCrashesConfiguration *)configuration;
Configures the error messaging mechanism for the app. To enable or disable specific types of error messages and configure associated parameters, use the properties of the AMAAppMetricaCrashesConfiguration class. Once set up, the configuration controls how the app handles different types of errors and issues.
Parameter:
|
AMAAppMetricaCrashesConfiguration object that defines how the app handles and reports errors. |
Example:
AMAAppMetricaCrashesConfiguration *config = [AMAAppMetricaCrashesConfiguration new];
config.autoCrashTracking = YES;
config.probablyUnhandledCrashReporting = NO;
config.applicationNotRespondingDetection = YES;
config.applicationNotRespondingWatchdogInterval = 5.0;
[[AMAAppMetricaCrashes crashes] setConfiguration:config];
-reportNSError:onFailure:
- (void)reportNSError:(NSError *)error
onFailure:(nullable void (^)(NSError *error))onFailure report(nserror:onFailure:);
Sends an NSError
message that is subject to certain restrictions on domain
, userInfo
, and other properties.
You can enable NSError
backtracing by using the AMABacktraceErrorKey
constant in the userInfo
property.
Restrictions:
domain
: No more than 200 characters.userInfo
: No more than 50 key-value pairs with keys no longer than 100 characters and values no longer than 2000 characters.NSUnderlyingErrorKey
: Using this key inuserInfo
enables you to include up to 10 errors.AMABacktraceErrorKey
: Using this key inuserInfo
enables you to include up to 200 stack frames in the backtrace.
AppMetrica truncates the value if it exceeds the specified limit.
Parameters:
|
The |
|
Callback method to call if an error occurs while sending the message. The |
-reportNSError:options:onFailure:
- (void)reportNSError:(NSError *)error
options:(AMAErrorReportingOptions)options
onFailure:(nullable void (^)(NSError *error))onFailure report(nserror:options:onFailure:);
Sends a custom NSError
message that adheres to the restrictions on domain
, userInfo
, and other properties.
You can enable NSError
backtracing by using the AMABacktraceErrorKey
constant in the userInfo
property.
Restrictions:
domain
: No more than 200 characters.userInfo
: No more than 50 key-value pairs with keys no longer than 100 characters and values no longer than 2000 characters.NSUnderlyingErrorKey
: Using this key inuserInfo
enables you to include up to 10 errors.AMABacktraceErrorKey
: Using this key inuserInfo
enables you to include up to 200 stack frames in the backtrace.
AppMetrica truncates the value if it exceeds any of these limits.
Parameters:
|
The |
|
Additional AMAErrorReportingOptions options that define how the error message is sent. |
|
Callback method to call if an error occurs while sending the message. The |
-reportError:onFailure:
- (void)reportError:(id<AMAErrorRepresentable>)error
onFailure:(nullable void (^)(NSError *error))onFailure report(error:onFailure:);
Sends a message about an error matching the AMAErrorRepresentable protocol.
Parameters:
|
Error that matches the |
|
Callback method to call if an error occurs while sending the message. The |
-reportError:options:onFailure:
- (void)reportError:(id<AMAErrorRepresentable>)error
options:(AMAErrorReportingOptions)options
onFailure:(nullable void (^)(NSError *error))onFailure report(error:options:onFailure:);
Sends a message about an error matching the AMAErrorRepresentable protocol, with additional options for message customization.
Parameters:
|
Error that matches the |
|
Additional AMAErrorReportingOptions options that define how the error message is sent. |
|
Callback method to call if an error occurs while sending the message. The |
-setErrorEnvironmentValue:forKey:
- (void)setErrorEnvironmentValue:(nullable NSString *)value
forKey:(NSString *)key set(errorEnvironmentValue:forKey:);
Sets the key-value pair that will be associated with errors and crashes. AppMetrica uses it as additional information for unhandled exceptions.
Parameters:
|
Value to associate with the key. Passing |
|
Key associated with the value. |
-clearErrorEnvironment:
- (void)clearErrorEnvironment;
Deletes all previously set key-value pairs associated with errors and crashes.
This method ensures that future unhandled exceptions won't have any extra information added, unless you set new key-value pairs.
To set a key-value pair, use -setErrorEnvironmentValue:forKey:.
-requestCrashReportingStateWithCompletionQueue:completionBlock:
- (void)requestCrashReportingStateWithCompletionQueue:(dispatch_queue_t)completionQueue
completionBlock:(AMACrashReportingStateCompletionBlock)completionBlock;
This method asynchronously fetches the current status of error messages and returns it via the completion block.
For more information about the dictionary with keys and their associated values, see AMACrashReportingStateCompletionBlock
.
Parameters:
|
Message queue that executes the completion block. |
|
Block to execute after completing the request. |
-enableANRMonitoring:
- (void)enableANRMonitoring;
Enables "Application Not Responding" (ANR) status monitoring with default parameters.
Use this method to enable ANR monitoring after activation only. To enable ANR monitoring during activation, use the applicationNotRespondingDetection
property in AMAAppMetricaCrashesConfiguration.
Default parameters:
watchdog
: 4 secondsping
: 0.1 seconds
-enableANRMonitoringWithWatchdogInterval:pingInterval:
- (void)enableANRMonitoringWithWatchdogInterval:(NSTimeInterval)watchdog
pingInterval:(NSTimeInterval)ping;
Enables "Application Not Responding" (ANR) status monitoring after activation only. To enable ANR monitoring during activation, use the applicationNotRespondingDetection
property in AMAAppMetricaCrashesConfiguration.
Parameters:
|
The timeout period before |
|
Frequency at which |
-reporterForAPIKey:
- (nullable id<AMAAppMetricaCrashReporting>)reporterForAPIKey:(NSString *)apiKey reporter(for:);
Returns an id<AMAAppMetricaCrashReporting>
that can send messages to a specific API key.
Parameter:
|
API key to send error reports to. |
Returns:
An id<AMAAppMetricaCrashReporting>
that matches the AMAAppMetricaCrashReporting
protocol and allows
sending messages to a specific API key.
-pluginExtension:
- (id<AMAAppMetricaPlugins>)pluginExtension;
Creates an AMAAppMetricaPlugins
instance that can send plugin events to the main API key. You can request it every time or store a reference for future use. To use this extension, first activate AppMetrica with the [AMAAppMetrica activateWithConfiguration:]
method.
Returns:
A plugin extension instance.