Migrating to version 5.0.0
When you migrate your app from YandexMobileMetrica to AppMetrica, the main IDs and data are preserved. That means the transition to the new version should not result in issues or anomalies in the reports.
To migrate to the new version, follow these steps:
- Replace dependencies. The required changes are provided in the dependency renaming section.
- Make sure you're not using 2 AppMetrica SDK versions in parallel.
- Import dependencies in the code. The required changes are provide in the dependency importing section.
- In the project code, replace the classes and methods that were simply renamed. The required changes are provided in the API renaming section.
- If you are using vendor keychain, replace the
com.yandex.mobile.appmetricapackage withio.appmetrica, see Device identification using a vendor keychain. - Switch to the new API to send errors using the instructions.
- Temporarily comment out the code with the other errors to ensure that the project can be built.
- Edit the code you commented out by following the other paragraphs in this guide. If you have any questions, contact support.
Renamed dependencies
pod 'YandexMobileMetrica', '~> 4.0'
Replace with:
pod 'AppMetricaAnalytics', '~> 5.0.0'
The AppMetrica SDK consists of multiple modules. This enables you to connect only the features you need. When AppMetricaAnalytics is connected, all modules are connected as well. For more detailed information about setting up, see the integration section.
If dependencies are set via Xcode
-
Delete the
metrika-sdk-iosdependency.
-
In the Xcode Project Navigator window, select your project (if Workspace is used). In the top menu, click File and select Add Package Dependencies....

-
Specify the repository URL
https://github.com/appmetrica/appmetrica-sdk-ios.
-
Leave only the required modules (to disable a module, select
NoneinAdd to Target):
AppMetricaCore: The mandatory main SDK module. It must be connected for working with AppMetrica.AppMetricaAdSupport: The module is used to collect IDs, including IDFA.AppMetricaCrashes: The module is intended for detecting crashes and sending errors.AppMetricaWebKit: The module enables you to send events from JavaScript code in WebView.
When using the Package.swift manifest
-
Delete the
.packagedependency withYandexMobileMetricafrom the filePackage.swiftin your project together with all references to the dependencies in thetargets:section within your project. -
Insert the following code to add the new
appmetrica-sdk-iosdependency:dependencies: [ .package( name: "AppMetrica", url: "https://github.com/appmetrica/appmetrica-sdk-ios", .upToNextMinor(from: "5.0.0") ), ], -
Add the required modules to your project's targets.
AppMetricaCore: The mandatory main SDK module. It must be connected for working with AppMetrica.AppMetricaAdSupport: The module is used to collect IDs, including IDFA.AppMetricaCrashes: The module is intended for detecting crashes and sending errors.AppMetricaWebKit: The module enables you to send events from JavaScript code in WebView.
.target( name: "MyTargetName", dependencies: [ .product(name: "AppMetricaCore", package: "AppMetrica"), .product(name: "AppMetricaCrashes", package: "AppMetrica"), .product(name: "AppMetricaWebKit", package: "AppMetrica"), // .product(name: "AppMetricaAdSupport", package: "AppMetrica"), // This module is disabled ] ),
Running two versions of AppMetrica SDK in parallel
We renamed the group and main artifacts. As a result, you can use two AppMetrica SDK versions in a single app in parallel: AppMetrica version 4 and lower (YandexMobileMetrica) and version 5 and higher (AppMetrica). This situation is not desirable and may occur only under certain conditions.
1. The app's dependencies include dependencies on two different AppMetrica SDK versions.
Alert
We strongly advise against simultaneously running YandexMobileMetrica and AppMetrica with the same API key in the app code. In other words, you can't use the same API key to enable both YandexMetrica and AppMetrica at the same time. While that won't cause crashes or failures in the app, it will distort and disrupt the statistics. When migrating to AppMetrica, make sure the app doesn't have the YandexMobileMetrica dependency.
2. One of the app's dependencies transitively depends on the AppMetrica SDK.
If the app and libraries use different API keys, this situation is acceptable but not desirable. The statistics should be collected normally, though minor deviations are possible. In that case, the app size might increase slightly since it will include two SDKs instead of one.
How to make sure that YandexMobileMetrica isn't used
Open Podfile.lock and search YandexMobileMetrica.
Using the PODS block in Podfile.lock, you can understand which dependency refers to YandexMobileMetrica.
PODS:
...
YandexMobileAds (6.4.0):
- DivKit (= 28.13.0)
- YandexMobileMetrica (< 5.0.0, >= 4.0.0)
...
If dependencies are set via Xcode
Open the project in Xcode. Make sure that Package Dependencies don't contain YandexMobileMetrica.

When using the Package.swift manifest
If your project uses the Package.swift manifest to manage dependencies, execute the swift package show-dependencies command in the terminal in your project's directory. This will output a list of all project dependencies, including transitive ones.
.
└── yandex-ads-sdk-ios<https://github.com/yandexmobile/yandex-ads-sdk-ios.git@6.4.0>
├── metrica-sdk-ios<https://github.com/yandexmobile/metrica-sdk-ios@4.5.2>
└── divkit-ios<https://github.com/divkit/divkit-ios@28.13.0>
└── vgsl<https://github.com/yandex/vgsl.git@2.4.1>
You can also check the Package.resolved file for the YandexMobileMetrica dependency.
{
"object": {
"pins": [
//...
{
"package": "YandexMobileMetrica",
"repositoryURL": "https://github.com/yandexmobile/metrica-sdk-ios",
"state": {
"branch": null,
"revision": "13d8b11181a33938ef42759d49466a621df5e7db",
"version": "4.5.2"
}
},
//...
]
},
// ...
}
Importing dependencies
import YandexMobileMetrica
Replace with:
import AppMetricaCore
import AppMetricaCrashes // if you need to work with errors/crashes
import AppMetricaWebKit // if you need to set up event sending from WebView
#import <YandexMobileMetrica/YandexMobileMetrica.h>
Replace with:
#import <AppMetricaCore/AppMetricaCore.h>
#import <AppMetricaCrashes/AppMetricaCrashes.h> // if you need to work with errors/crashes
#import <AppMetricaWebKit/AppMetricaWebKit.h> // if you need to set up event sending from WebView
Renaming the API
Removed the YMM prefix.
- Renamed the
YMMYandexMetricainterface toAppMetrica.- Renamed the
handleOpen(_:)method totrackOpeningURL(_:). - Renamed the
initWebViewReporting(_:onFailure:)method tosetupWebViewReporting(with:onFailure:). For more information, see Sending an event from the WebView's JavaScript code. - Removed the
libraryVersion()method, use thelibraryVersionproperty. - Renamed the
report(adRevenue:onFailure:)method toreportAdRevenue(_:onFailure). - Renamed the
report(eCommerce:onFailure:)method toreportECommerce(_:onFailure:). - Moved the
report(error:onFailure:)method to theAppMetricaCrashesclass and theAppMetricaCrashesmodule, see Working with crashes and errors. - Moved the
report(error:options:onFailure:)method to theAppMetricaCrashesclass and theAppMetricaCrashesmodule, see Working with crashes and errors. - Moved the
report(nserror:onFailure:)method to theAppMetricaCrashesclass and theAppMetricaCrashesmodule, see Working with crashes and errors. - Moved the
report(nserror:options:onFailure:)method to theAppMetricaCrashesclass and theAppMetricaCrashesmodule, see Working with crashes and errors. - Removed the
reportError(_:exception:onFailure:)method, see Working with crashes and errors. - Renamed the
reportEvent(_:onFailure:)method toreportEvent(name:onFailure). - Renamed the
reportEvent(_:parameters:onFailure:)method toreportEvent(name:parameters:onFailure). - Removed the
reportReferralUrl(_:)method. - Renamed the
reporterForApiKey(_:)method toreporter(for:). - Removed the
requestAppMetricaDeviceID(withCompletionQueue:completionBlock:)method, userequestStartupIdentifiers(for:on:completion:). - Removed the
setErrorEnvironmentValue(_:forKey:)method, useAppMetricaCrashes.crashes().set(errorEnvironmentValue: value, forKey: key). - Removed the
setLocation(_:)method, use thecustomLocationproperty. - Removed the
setLocationTracking(_:)method, use theisLocationTrackingEnabledproperty. - Renamed the
setStatisticsSending(_:)method tosetDataSendingEnabled(_:). - Removed the
setUserProfileID(_:)method, use theuserProfileIDproperty.
- Renamed the
- Renamed the
YMMYandexMetricaConfigurationinterface toAppMetricaConfiguration- Removed the
appForKidsproperty, see Using the SDK for children's apps. - Removed the
crashReportingproperty, see Working with crashes and errors. - Renamed the
locationproperty tocustomLocation. - Renamed the
logsproperty toareLogsEnabled. - Renamed the
statisticsSendingproperty asdataSendingEnabled.
- Removed the
- Renamed the
YMMYandexMetricaPreloadInfointerface toAppMetricaPreloadInfo.- Renamed the
setAdditional(_:forKey:)method tosetAdditional(info:forKey:).
- Renamed the
Reporter
- Renamed the
YMMMutableReporterConfigurationinterface toMutableReporterConfiguration.- Renamed the
logsproperty toareLogsEnabled. - Renamed the
statisticsSendingproperty asdataSendingEnabled.
- Renamed the
- Renamed the
YMMPluginErrorDetailsinterface toPluginErrorDetails. - Renamed the
YMMReporterConfigurationinterface toReporterConfiguration.- Renamed the
logsproperty toareLogsEnabled. - Renamed the
statisticsSendingproperty asdataSendingEnabled.
- Renamed the
- Added the
AppMetricaCrashesConfigurationinterface. - Renamed the
YMMStackTraceElementinterface toStackTraceElement. - Renamed the
YMMYandexMetricaPluginsinterface toAppMetricaPlugins.- Renamed the
getPluginExtensionmethod topluginExtension.
- Renamed the
- Added the
AppMetricaCrashesinterface.- Added the
-clearErrorEnvironment:method. - Added the
-enableANRMonitoring:method. - Added the
-enableANRMonitoringWithWatchdogInterval:pingInterval:method. - Added the
-requestCrashReportingStateWithCompletionQueue:completionBlock:method. - Added the
-setErrorEnvironmentValue:forKey:method.
- Added the
- Renamed the
YMMYandexMetricaPluginReportingprotocol toAppMetricaPluginReporting.- Renamed the
getPluginExtensionmethod topluginExtension.
- Renamed the
- Renamed the
YMMYandexMetricaReportingprotocol toAppMetricaReporting.- Renamed the
report(adRevenue:onFailure:)method toreportAdRevenue(_:onFailure). - Renamed the
report(eCommerce:onFailure:)method toreportECommerce(_:onFailure:). - Moved the
report(error:onFailure:)method to theAppMetricaCrashReportingprotocol, theAppMetricaCrashesclass, and theAppMetricaCrashesmodule, see Working with crashes and errors. - Moved the
report(error:options:onFailure:)method to theAppMetricaCrashReportingprotocol, theAppMetricaCrashesclass, and theAppMetricaCrashesmodule, see Working with crashes and errors. - Moved the
report(nserror:onFailure:)method to theAppMetricaCrashReportingprotocol, theAppMetricaCrashesclass, and theAppMetricaCrashesmodule, see Working with crashes and errors. - Moved the
report(nserror:options:onFailure:)method to theAppMetricaCrashReportingprotocol, theAppMetricaCrashesclass, and theAppMetricaCrashesmodule, see Working with crashes and errors. - Renamed the
reportEvent(_:onFailure:)method toreportEvent(name:onFailure). - Renamed the
reportEvent(_:parameters:onFailure:)method toreportEvent(name:parameters:onFailure). - Renamed the
setStatisticsSending(_:)method tosetDataSendingEnabled(_:). - Removed the
setUserProfileID(_:)method, use theuserProfileIDproperty.
- Renamed the
- Renamed the
kYMMPlatformNativeconstant toPlatformNative. - Renamed the
kYMMPlatformFlutterconstant toPlatformFlutter. - Added the
CrashReportingStateKey.enabledKeyconstant. - Added the
CrashReportingStateKey.crashedLastLaunchKeyconstant.
User attributes
- Renamed the
YMMMutableUserProfileinterface toMutableUserProfile. - Renamed the
YMMProfileAttributeinterface toProfileAttribute. - Renamed the
YMMUserProfileinterface toUserProfile. - Renamed the
YMMGenderTypeenumeration toGenderType. - Renamed the
YMMBirthDateAttributeprotocol toBirthDateAttribute. - Renamed the
YMMCustomBoolAttributeprotocol toCustomBoolAttribute. - Renamed the
YMMCustomCounterAttributeprotocol toCustomCounterAttribute. - Renamed the
YMMCustomNumberAttributeprotocol toCustomNumberAttribute. - Renamed the
YMMCustomStringAttributeprotocol toCustomStringAttribute. - Renamed the
YMMGenderAttributeprotocol toGenderAttribute. - Renamed the
YMMNameAttributeprotocol toNameAttribute. - Renamed the
YMMNotificationsEnabledAttributeprotocol toNotificationsEnabledAttribute.
Errors
- Renamed the
YMMErrorinterface toAppMetricaErrorand moved it to theAppMetricaCrashesmodule. - Renamed the
YMMBacktraceErrorKeyconstant toBacktraceErrorKeyand moved it to theAppMetricaCrashesmodule. - Renamed the
YMMErrorReportingOptionsenumeration asErrorReportingOptionsand moved it to theAppMetricaCrashesmodule. - Renamed the
YMMErrorRepresentableprotocol toErrorRepresentableand moved it to theAppMetricaCrashesmodule.
AdRevenue
- Renamed the
YMMAdRevenueInfointerface toAdRevenueInfo. - Renamed the
YMMMutableAdRevenueInfointerface toMutableAdRevenueInfo. - Renamed the
YMMAdTypeenumeration toAdType.
ECommerce
- Renamed the
YMMECommerceAmountinterface toECommerceAmount. - Renamed the
YMMECommerceCartIteminterface toECommerceCartItem. - Renamed the
YMMECommerceOrderinterface toECommerceOrder. - Renamed the
YMMECommercePriceinterface toECommercePrice. - Renamed the
YMMECommerceProductinterface toECommerceProduct. - Renamed the
YMMECommerceReferrerinterface toECommerceReferrer. - Renamed the
YMMECommerceScreeninterface toECommerceScreen. - Renamed the
YMMECommerceinterface toECommerce.
Revenue
- Renamed the
YMMMutableRevenueInfointerface toMutableRevenueInfo. - Renamed the
YMMRevenueInfointerface toRevenueInfo.- Removed the
init(price:currency:)constructor, useinit(priceDecimal:currency). - Removed the
init(price:currency:quantity:productID:transactionID:receiptData:payload:)constructor, useinit(priceDecimal:currency:quantity:productID:transactionID:receiptData:payload:).
- Removed the
Changed the YMM prefix to AMA.
- Renamed the
YMMYandexMetricainterface toAMAAppMetrica.- Renamed the
-getPluginExtension:method to-pluginExtension:and moved it to theAMAAppMetricaCrashesclass. - Renamed the
+handleOpenURL:method to+trackOpeningURL:. - Renamed the
+initWebViewReporting:onFailure:method to+setupWebViewReporting:onFailure:. For more information, see Sending an event from the WebView's JavaScript code. - Removed the
+libraryVersion:method, use thelibraryVersionproperty. - Removed the
+reportError:exception:onFailure:method, see Working with crashes and errors. - Moved the
+reportError:onFailure:method to theAppMetricaCrashesclass and theAppMetricaCrashesmodule, see Working with crashes and errors. - Moved the
+reportError:options:onFailure:method to theAppMetricaCrashesclass and theAppMetricaCrashesmodule, see Working with crashes and errors. - Renamed the
+reportEvent:params:onFailure:method to+reportEvent:parameters:onFailure: - Moved the
+reportNSError:onFailure:method to theAppMetricaCrashesclass and theAppMetricaCrashesmodule, see Working with crashes and errors. - Moved the
+reportNSError:options:onFailure:method to theAppMetricaCrashesclass and theAppMetricaCrashesmodule, see Working with crashes and errors. - Removed the
+reportReferralUrl:method. - Renamed the
+reporterForApiKey:method to+reporterForAPIKey:. - Removed the
+requestAppMetricaDeviceIDWithCompletionQueue:method, use+requestStartupIdentifiersWithKeys:completionQueue:completionBlock:. - Removed the
+setErrorEnvironmentValue:forKey:method, use[[AMAAppMetricaCrashes crashes] setErrorEnvironmentValue:value forKey:key]. - Removed the
+setLocation:method, use thecustomLocationproperty. - Removed the
+setLocationTracking:method, use thelocationTrackingEnabledproperty. - Renamed the
+setStatisticsSending:method as+setDataSendingEnabled:. - Removed the
+setUserProfileID:method, use theuserProfileIDproperty.
- Renamed the
- Renamed the
YMMYandexMetricaConfigurationinterface toAMAAppMetricaConfiguration.- Renamed the
-initWithApiKey:constructor as-initWithAPIKey:. - Renamed the
apiKeyproperty toAPIKey. - Removed the
appForKidsproperty, see Using the SDK for children's apps. - Removed the
crashReportingproperty, see Working with crashes and errors. - Renamed the
locationproperty tocustomLocation. - Renamed the
logsproperty aslogsEnabled. - Renamed the
statisticsSendingproperty todataSendingEnabled.
- Renamed the
- Renamed the
YMMYandexMetricaPreloadInfointerface toAMAAppMetricaPreloadInfo.
Reporter
- Renamed the
YMMMutableReporterConfigurationinterface toAMAMutableReporterConfiguration.- Renamed the
logsproperty tologsEnabled. - Renamed the
statisticsSendingproperty todataSendingEnabled.
- Renamed the
- Renamed the
YMMPluginErrorDetailsinterface toAMAPluginErrorDetails. - Renamed the
YMMReporterConfigurationinterface toAMAReporterConfiguration.- Renamed the
-initWithApiKey:constructor to-initWithAPIKey:. - Renamed the
apiKeyproperty toAPIKey. - Renamed the
logsproperty tologsEnabled. - Renamed the
statisticsSendingproperty todataSendingEnabled.
- Renamed the
- Added the
AMAAppMetricaCrashesConfigurationinterface. - Renamed the
YMMStackTraceElementinterface toAMAStackTraceElement. - Renamed the
YMMYandexMetricaPluginsinterface toAMAAppMetricaPlugins.- Renamed the
getPluginExtensionmethod topluginExtension.
- Renamed the
- Added the
AMAAppMetricaCrashesinterface.- Added the
-clearErrorEnvironment:method. - Added the
-enableANRMonitoring:method. - Added the
-enableANRMonitoringWithWatchdogInterval:pingInterval:method. - Added the
-requestCrashReportingStateWithCompletionQueue:completionBlock:method. - Added the
-setErrorEnvironmentValue:forKey:method.
- Added the
- Renamed the
YMMYandexMetricaPluginReportingprotocol toAMAAppMetricaPluginReporting.- Renamed the
getPluginExtensionmethod topluginExtension.
- Renamed the
- Renamed the
YMMYandexMetricaReportingprotocol toAMAAppMetricaReporting.- Moved the
+reportError:onFailure:method to theAMAAppMetricaCrashReportingprotocol, theAppMetricaCrashesclass, and theAppMetricaCrashesmodule, see Working with crashes and errors. - Moved the
+reportError:options:onFailure:method to theAMAAppMetricaCrashReportingprotocol, theAppMetricaCrashesclass, and theAppMetricaCrashesmodule, see Working with crashes and errors. - Renamed the
+reportEvent:params:onFailure:method to+reportEvent:parameters:onFailure:. - Moved the
+reportNSError:onFailure:method to theAMAAppMetricaCrashReportingprotocol, theAppMetricaCrashesclass, and theAppMetricaCrashesmodule, see Working with crashes and errors. - Moved the
+reportNSError:options:onFailure:method to theAMAAppMetricaCrashReportingprotocol, theAppMetricaCrashesclass, and theAppMetricaCrashesmodule, see Working with crashes and errors. - Renamed the
+setStatisticsSending:method to+setDataSendingEnabled:.
- Moved the
- Renamed the
kYMMPlatformNativeconstant tokAMAPlatformNative. - Renamed the
kYMMPlatformFlutterconstant tokAMAPlatformFlutter. - Added the
kAMACrashReportingStateCrashedLastLaunchKeyconstant starting from version 5.4.0. - Added the
kAMACrashReportingStateEnabledKeyconstant starting from version 5.4.0.
User attributes
- Renamed the
YMMMutableUserProfileinterface toAMAMutableUserProfile. - Renamed the
YMMProfileAttributeinterface toAMAProfileAttribute. - Renamed the
YMMUserProfileinterface toAMAUserProfile. - Renamed the
YMMGenderTypeenumeration toAMAGenderType. - Renamed the
YMMBirthDateAttributeprotocol toAMABirthDateAttribute. - Renamed the
YMMCustomBoolAttributeprotocol toAMACustomBoolAttribute. - Renamed the
YMMCustomCounterAttributeprotocol toAMACustomCounterAttribute. - Renamed the
YMMCustomNumberAttributeprotocol toAMACustomNumberAttribute. - Renamed the
YMMCustomStringAttributeprotocol toAMACustomStringAttribute. - Renamed the
YMMGenderAttributeprotocol toAMAGenderAttribute. - Renamed the
YMMNameAttributeprotocol toAMANameAttribute. - Renamed the
YMMNotificationsEnabledAttributeprotocol toAMANotificationsEnabledAttribute.
Errors
- Renamed the
YMMErrorinterface toAMAError. - Renamed the
YMMBacktraceErrorKeyconstant toAMABacktraceErrorKey. - Renamed the
YMMErrorReportingOptionsenumeration toAMAErrorReportingOptions. - Renamed the
YMMErrorRepresentableprotocol toAMAErrorRepresentable.
AdRevenue
- Renamed the
YMMAdRevenueInfointerface toAMAAdRevenueInfo. - Renamed the
YMMMutableAdRevenueInfointerface toAMAMutableAdRevenueInfo. - Renamed the
YMMAdTypeenumeration toAMAAdType.
ECommerce
- Renamed the
YMMECommerceAmountinterface toAMAECommerceAmount. - Renamed the
YMMECommerceCartIteminterface toAMAECommerceCartItem. - Renamed the
YMMECommerceOrderinterface toAMAECommerceOrder. - Renamed the
YMMECommercePriceinterface toAMAECommercePrice. - Renamed the
YMMECommerceProductinterface toAMAECommerceProduct. - Renamed the
YMMECommerceReferrerinterface toAMAECommerceReferrer. - Renamed the
YMMECommerceScreeninterface toAMAECommerceScreen. - Renamed the
YMMECommerceinterface toAMAECommerce.
Revenue
- Renamed the
YMMMutableRevenueInfointerface toAMAMutableRevenueInfo. - Renamed the
YMMRevenueInfointerface toAMARevenueInfo.- Removed the
-initWithPrice:currency:constructor, use-initWithPriceDecimal:currency:. - Removed the
-initWithPrice:currency:quantity:productID:transactionID:receiptData:payload:constructor, use-initWithPriceDecimal:currency:quantity:productID:transactionID:receiptData:payload:.
- Removed the
Working with crashes and errors
The API for working with errors is now in the AppMetricaCrashes module. If you're connecting AppMetricaAnalytics, you don't need to connect AppMetricaCrashes separately, because the module is included in AppMetricaAnalytics.
Add the import to all files where you use crash or error API resources:
import AppMetricaCrashes
The crash sending logic is defined with the AppMetricaCrashesConfiguration class:
var configuration = AppMetricaCrashesConfiguration()
configuration.autoCrashTracking = true // If this parameter is enabled, crashes are automatically sent to AppMetrca
configuration.probablyUnhandledCrashReporting = true // Use this parameter to enable or disable tracking of implicit failures, such as OOM crashes
configuration.ignoredCrashSignals = [] // This setting enables you to specify an array of UNIX signals from sys/signal.h that will be ignored by the failure tracking system
configuration.applicationNotRespondingDetection = true // This setting includes detecting situations when the main app thread stops responding (ANR)
configuration.applicationNotRespondingWatchdogInterval = 4.0 // Sets the time interval that the watchdog will wait before reporting the "Application Not Responding" status (ANR)
configuration.applicationNotRespondingPingInterval = 0.1 // Sets the frequency at which watchdog will check the "Application Not Responding" status (ANR)
AppMetricaCrashes.crashes().setConfiguration(configuration)
To send errors, use methods of the AppMetricaCrashes class. Their signature matches that of similar methods from YMMYandexMetrica, so all you need to do is replace YMMYandexMetrica with AppMetricaCrashes.crashes().
AppMetricaCrashes.crashes().report(error:error)
AppMetricaCrashes.crashes().report(error:error, onFailure:nil)
AppMetricaCrashes.crashes().report(error:error, options:options, onFailure:nil)
AppMetricaCrashes.crashes().report(nserror:error)
AppMetricaCrashes.crashes().report(nserror:error, onFailure:nil)
AppMetricaCrashes.crashes().report(nserror:error, options:options, onFailure:nil)
Add the import to all files where you use crash or error API resources:
#import <AppMetricaCrashes/AppMetricaCrashes.h>
The crash sending logic is defined with the AMAAppMetricaCrashesConfiguration class:
AMAAppMetricaCrashesConfiguration *configuration = [[AMAAppMetricaCrashesConfiguration alloc] init];
configuration.autoCrashTracking = YES; // If this parameter is enabled, crashes are automatically sent to AppMetrca
configuration.probablyUnhandledCrashReporting = YES; // Use this parameter to enable or disable tracking of implicit failures, such as OOM crashes
configuration.ignoredCrashSignals = @[]; // This setting enables you to specify an array of UNIX signals from sys/signal.h that will be ignored by the failure tracking system
configuration.applicationNotRespondingDetection = YES; // This setting includes detecting situations when the main app thread stops responding (ANR)
configuration.applicationNotRespondingWatchdogInterval = 4.0; // Sets the time interval that the watchdog will wait before reporting the "Application Not Responding" status (ANR)
configuration.applicationNotRespondingPingInterval = 0.1; // Sets the frequency at which watchdog will check the "Application Not Responding" status (ANR)
[[AMAAppMetricaCrashes crashes] setConfiguration:configuration];
To send errors, use methods of the AppMetricaCrashes class. Their signature matches that of similar methods from YMMYandexMetrica, so all you need to do is replace YMMYandexMetrica with [AMAAppMetricaCrashes crashes].
[[AMAAppMetricaCrashes crashes] reportError:error onFailure:nil];
[[AMAAppMetricaCrashes crashes] reportError:error options:options onFailure:nil];
[[AMAAppMetricaCrashes crashes] reportNSError:error onFailure:nil];
[[AMAAppMetricaCrashes crashes] reportNSError:error options:options onFailure:nil];
For more information about sending errors, see usage examples.
Sending an event from WebView's JavaScript code
The API for setting up event sending from WebView's JavaScript code is now in the AppMetricaWebKit module. If you're connecting AppMetricaAnalytics, you don't need to connect AppMetricaWebKit separately, because the module is included in AppMetricaAnalytics.
Add the following string in each file where the WebView setting within the AppMetrica library is used:
import AppMetricaWebKit
You need to replace the WKUserContentController instance with the instance of the JSController wrapping. Replace:
let userController = WKUserContentController()
YMMYandexMetrica.initWebViewReporting(userController, onFailure: nil)
with
let userController = WKUserContentController()
AppMetrica.setupWebViewReporting(with: JSController(userContentController: userController), onFailure: nil)
Add the following string in each file where the WebView setting is used:
#import <AppMetricaWebKit/AppMetricaWebKit.h>
You need to replace the WKUserContentController instance with the instance of the AMAJSController wrapping. Replace:
WKUserContentController *userController = [[WKUserContentController alloc] init];
[YMMYandexMetrica initWebViewReporting:userController onFailure:nil];
with
WKUserContentController *userController = [[WKUserContentController alloc] init];
[AMAAppMetrica setupWebViewReporting:[[AMAJSController alloc] initWithUserContentController:userController] onFailure:nil];
For more information about setting up event sending from WebView, see usage examples.
Using the SDK for children's apps
To use the SDK in a children's app, exclude the AppMetricaAdSupport module.
Instead of
pod 'AppMetricaAnalytics', '~> 5.0.0'
use
pod 'AppMetricaCore', '~> 5.0.0'
pod 'AppMetricaCrashes', '~> 5.0.0' # if you need crashes and errors
pod 'AppMetricaWebKit', '~> 5.0.0' # if you need to send events from WebView
If dependencies are set via Xcode
Exclude AppMetricaAdSupport from Frameworks, Libraries, and Embedded Content for your target.

When using the Package.swift manifest
Disable the AppMetricaAdSupport module:
.target(
name: "MyTargetName",
dependencies: [
.product(name: "AppMetricaCore", package: "AppMetrica"),
.product(name: "AppMetricaCrashes", package: "AppMetrica"),
.product(name: "AppMetricaWebKit", package: "AppMetrica"),
// .product(name: "AppMetricaAdSupport", package: "AppMetrica"), // This module is disabled
]
),
If you didn't find the answer you were looking for, you can use the feedback form to submit your question. Please describe the problem in as much detail as possible. Attach a screenshot if possible.