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.
- 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-ios
dependency. -
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
None
inAdd 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
.package
dependency withYandexMobileMetrica
from the filePackage.swift
in 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-ios
dependency: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 Package.resolved
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
YMMYandexMetrica
interface asAppMetrica
.- Renamed the
handleOpen(_:)
method astrackOpeningURL(_:)
. - Renamed the
initWebViewReporting(_:onFailure:)
method assetupWebViewReporting(with:onFailure:)
. For more information, see Sending an event from the WebView's JavaScript code. - Removed the
libraryVersion()
method, use thelibraryVersion
property. - Renamed the
report(adRevenue:onFailure:)
method asreportAdRevenue(_:onFailure)
. - Renamed the
report(eCommerce:onFailure:)
method asreportECommerce(_:onFailure:)
. - Moved the
report(error:onFailure:)
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
report(error:options:onFailure:)
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
report(nserror:onFailure:)
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
report(nserror:options:onFailure:)
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Removed the
reportError(_:exception:onFailure:)
method, see Working with crashes and errors. - Renamed the
reportEvent(_:onFailure:)
method asreportEvent(name:onFailure)
. - Renamed the
reportEvent(_:parameters:onFailure:)
method asreportEvent(name:parameters:onFailure)
. - Removed the
reportReferralUrl(_:)
method. - Renamed the
reporterForApiKey(_:)
method asreporter(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 thecustomLocation
property. - Removed the
setLocationTracking(_:)
method, use theisLocationTrackingEnabled
property. - Renamed the
setStatisticsSending(_:)
method assetDataSendingEnabled(_:)
. - Removed the
setUserProfileID(_:)
method, use theuserProfileID
property.
- Renamed the
- Renamed the
YMMYandexMetricaConfiguration
interface asAppMetricaConfiguration
- Removed the
appForKids
property, see Using the SDK for children's apps. - Removed the
crashReporting
property, see Working with crashes and errors. - Renamed the
location
property ascustomLocation
. - Renamed the
logs
property asareLogsEnabled
. - Renamed the
statisticsSending
property asdataSendingEnabled
.
- Removed the
- Renamed the
YMMYandexMetricaPreloadInfo
interface asAppMetricaPreloadInfo
.- Renamed the
setAdditional(_:forKey:)
method assetAdditional(info:forKey:)
.
- Renamed the
Reporter
- Renamed the
YMMMutableReporterConfiguration
interface asMutableReporterConfiguration
.- Renamed the
logs
property asareLogsEnabled
. - Renamed the
statisticsSending
property asdataSendingEnabled
.
- Renamed the
- Renamed the
YMMReporterConfiguration
interface asReporterConfiguration
.- Renamed the
logs
property asareLogsEnabled
. - Renamed the
statisticsSending
property asdataSendingEnabled
.
- Renamed the
- Renamed the
YMMYandexMetricaReporting
protocol asAppMetricaReporting
.- Renamed the
report(adRevenue:onFailure:)
method asreportAdRevenue(_:onFailure)
. - Renamed the
report(eCommerce:onFailure:)
method asreportECommerce(_:onFailure:)
. - Moved the
report(error:onFailure:)
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
report(error:options:onFailure:)
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
report(nserror:onFailure:)
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
report(nserror:options:onFailure:)
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Renamed the
reportEvent(_:onFailure:)
method asreportEvent(name:onFailure)
. - Renamed the
reportEvent(_:parameters:onFailure:)
method asreportEvent(name:parameters:onFailure)
. - Renamed the
setStatisticsSending(_:)
method assetDataSendingEnabled(_:)
. - Removed the
setUserProfileID(_:)
method, use theuserProfileID
property.
- Renamed the
User attributes
- Renamed the
YMMMutableUserProfile
interface asMutableUserProfile
. - Renamed the
YMMProfileAttribute
interface asProfileAttribute
. - Renamed the
YMMUserProfile
interface asUserProfile
. - Renamed the
YMMGenderType
enumeration asGenderType
. - Renamed the
YMMBirthDateAttribute
protocol asBirthDateAttribute
. - Renamed the
YMMCustomBoolAttribute
protocol asCustomBoolAttribute
. - Renamed the
YMMCustomCounterAttribute
protocol asCustomCounterAttribute
. - Renamed the
YMMCustomNumberAttribute
protocol asCustomNumberAttribute
. - Renamed the
YMMCustomStringAttribute
protocol asCustomStringAttribute
. - Renamed the
YMMGenderAttribute
protocol asGenderAttribute
. - Renamed the
YMMNameAttribute
protocol asNameAttribute
. - Renamed the
YMMNotificationsEnabledAttribute
protocol asNotificationsEnabledAttribute
.
Errors
- Renamed the
YMMError
interface asAppMetricaError
and moved it to theAppMetricaCrashes
module. - Renamed the
YMMBacktraceErrorKey
constant asBacktraceErrorKey
and moved it to theAppMetricaCrashes
module. - Renamed the
YMMErrorReportingOptions
enumeration asErrorReportingOptions
and moved it to theAppMetricaCrashes
module. - Renamed the
YMMErrorRepresentable
protocol asErrorRepresentable
and moved it to theAppMetricaCrashes
module.
AdRevenue
- Renamed the
YMMAdRevenueInfo
interface asAdRevenueInfo
. - Renamed the
YMMMutableAdRevenueInfo
interface asMutableAdRevenueInfo
. - Renamed the
YMMAdType
enumeration asAdType
.
ECommerce
- Renamed the
YMMECommerceAmount
interface asECommerceAmount
. - Renamed the
YMMECommerceCartItem
interface asECommerceCartItem
. - Renamed the
YMMECommerceOrder
interface asECommerceOrder
. - Renamed the
YMMECommercePrice
interface asECommercePrice
. - Renamed the
YMMECommerceProduct
interface asECommerceProduct
. - Renamed the
YMMECommerceReferrer
interface asECommerceReferrer
. - Renamed the
YMMECommerceScreen
interface asECommerceScreen
. - Renamed the
YMMECommerce
interface asECommerce
.
Revenue
- Renamed the
YMMMutableRevenueInfo
interface asMutableRevenueInfo
. - Renamed the
YMMRevenueInfo
interface asRevenueInfo
.- 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
YMMYandexMetrica
interface asAMAAppMetrica
.- Renamed the
+handleOpenURL:
method as+trackOpeningURL:
. - Renamed the
+initWebViewReporting:onFailure:
method as+setupWebViewReporting:onFailure:
. For more information, see Sending an event from the WebView's JavaScript code. - Removed the
+libraryVersion:
method, use thelibraryVersion
property. - Removed the
+reportError:exception:onFailure:
method, see Working with crashes and errors - Moved the
+reportError:onFailure:
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
+reportError:options:onFailure:
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Renamed the
+reportEvent:params:onFailure:
method as+reportEvent:parameters:onFailure:
- Moved the
+reportNSError:onFailure:
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
+reportNSError:options:onFailure:
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Removed the
+reportReferralUrl:
method. - Renamed the
+reporterForApiKey:
method as+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 thecustomLocation
property. - Removed the
+setLocationTracking:
method, use thelocationTrackingEnabled
property. - Renamed the
+setStatisticsSending:
method as+setDataSendingEnabled:
. - Removed the
+setUserProfileID:
method, use theuserProfileID
property.
- Renamed the
- Renamed the
YMMYandexMetricaConfiguration
interface asAMAAppMetricaConfiguration
.- Renamed the
-initWithApiKey:
constructor as-initWithAPIKey:
. - Renamed the
apiKey
property asAPIKey
. - Removed the
appForKids
property, see Using the SDK for children's apps. - Removed the
crashReporting
property, see Working with crashes and errors. - Renamed the
location
property ascustomLocation
. - Renamed the
logs
property aslogsEnabled
. - Renamed the
statisticsSending
property asdataSendingEnabled
.
- Renamed the
- Renamed the
YMMYandexMetricaPreloadInfo
interface asAMAAppMetricaPreloadInfo
.
Reporter
- Renamed the
YMMMutableReporterConfiguration
interface asAMAMutableReporterConfiguration
.- Renamed the
logs
property aslogsEnabled
. - Renamed the
statisticsSending
property asdataSendingEnabled
.
- Renamed the
- Renamed the
YMMReporterConfiguration
interface asAMAReporterConfiguration
.- Renamed the
-initWithApiKey:
constructor as-initWithAPIKey:
. - Renamed the
apiKey
property asAPIKey
. - Renamed the
logs
property aslogsEnabled
. - Renamed the
statisticsSending
property asdataSendingEnabled
.
- Renamed the
- Renamed the
YMMYandexMetricaReporting
protocol asAMAAppMetricaReporting
.- Moved the
+reportError:onFailure:
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
+reportError:options:onFailure:
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Renamed the
+reportEvent:params:onFailure:
method as+reportEvent:parameters:onFailure:
. - Moved the
+reportNSError:onFailure:
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
+reportNSError:options:onFailure:
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Renamed the
+setStatisticsSending:
method as+setDataSendingEnabled:
.
- Moved the
User attributes
- Renamed the
YMMMutableUserProfile
interface asAMAMutableUserProfile
. - Renamed the
YMMProfileAttribute
interface asAMAProfileAttribute
. - Renamed the
YMMUserProfile
interface asAMAUserProfile
. - Renamed the
YMMGenderType
enumeration asAMAGenderType
. - Renamed the
YMMBirthDateAttribute
protocol asAMABirthDateAttribute
. - Renamed the
YMMCustomBoolAttribute
protocol asAMACustomBoolAttribute
. - Renamed the
YMMCustomCounterAttribute
protocol asAMACustomCounterAttribute
. - Renamed the
YMMCustomNumberAttribute
protocol asAMACustomNumberAttribute
. - Renamed the
YMMCustomStringAttribute
protocol asAMACustomStringAttribute
. - Renamed the
YMMGenderAttribute
protocol asAMAGenderAttribute
. - Renamed the
YMMNameAttribute
protocol asAMANameAttribute
. - Renamed the
YMMNotificationsEnabledAttribute
protocol asAMANotificationsEnabledAttribute
.
Errors
- Renamed the
YMMError
interface asAMAError
. - Renamed the
YMMBacktraceErrorKey
constant asAMABacktraceErrorKey
. - Renamed the
YMMErrorReportingOptions
enumeration asAMAErrorReportingOptions
. - Renamed the
YMMErrorRepresentable
protocol asAMAErrorRepresentable
.
AdRevenue
- Renamed the
YMMAdRevenueInfo
interface asAMAAdRevenueInfo
. - Renamed the
YMMMutableAdRevenueInfo
interface asAMAMutableAdRevenueInfo
. - Renamed the
YMMAdType
enumeration asAMAAdType
.
ECommerce
- Renamed the
YMMECommerceAmount
interface asAMAECommerceAmount
. - Renamed the
YMMECommerceCartItem
interface asAMAECommerceCartItem
. - Renamed the
YMMECommerceOrder
interface asAMAECommerceOrder
. - Renamed the
YMMECommercePrice
interface asAMAECommercePrice
. - Renamed the
YMMECommerceProduct
interface asAMAECommerceProduct
. - Renamed the
YMMECommerceReferrer
interface asAMAECommerceReferrer
. - Renamed the
YMMECommerceScreen
interface asAMAECommerceScreen
. - Renamed the
YMMECommerce
interface asAMAECommerce
.
Revenue
- Renamed the
YMMMutableRevenueInfo
interface asAMAMutableRevenueInfo
. - Renamed the
YMMRevenueInfo
interface asAMARevenueInfo
.- 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.
Was the article helpful?
- Renamed dependencies
- Running two versions of AppMetrica SDK in parallel
- 1. The app's dependencies include dependencies on two different AppMetrica SDK versions.
- 2. One of the app's dependencies transitively depends on the AppMetrica SDK.
- How to make sure that YandexMobileMetrica isn't used
- Importing dependencies
- Renaming the API
- Working with crashes and errors
- Sending an event from WebView's JavaScript code
- Using the SDK for children's apps