Migrating to version 2.0.0
When you migrate your app from YandexMobileMetricaPush
to AppMetricaPush
, the main IDs and data are preserved. That means the transition to the new version shouldn't result in issues or anomalies in the reports.
To migrate to the new version, follow these steps:
- Update AppMetrica SDK by following the guide.
- Replace dependencies. The required changes are provided in the dependency renaming section.
- Make sure you're not running two different AppMetrica Push 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 have any questions, contact support.
Renamed dependencies
pod 'YandexMobileMetricaPush', '~> 1.3.0'
Replace with:
pod 'AppMetricaPush', '~> 2.0.0' # Main module for working with Push SDK, it's required for connecting
pod 'AppMetricaPushLazy', '~> 2.0.0' # Additional module for lazy push notifications
When using the Package.swift manifest
-
Delete the
.package
dependency withmetrica-push-sdk-ios
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
push-sdk-ios
dependency:dependencies: [ .package( url: "https://github.com/appmetrica/push-sdk-ios", from: "2.0.0" ) ],
-
Add the required modules to your project's targets.
The AppMetrica Push SDK modules that you can enable depending on the needs of your project:
AppMetricaPush
: The main mandatory Push SDK module. You need to enable it to use AppMetrica.AppMetricaPushLazy
: Additional module for lazy push notifications.
.target( name: "MyTargetName", dependencies: [ .product(name: "AppMetricaPush", package: "push-sdk-ios"), // .product(name: "AppMetricaPushLazy", package: "push-sdk-ios"), // This module is disabled ] ),
Running two versions of AppMetrica Push SDK in parallel
We renamed the group and main artifacts. As a result, you can use two AppMetrica Push SDK versions in a single app in parallel: AppMetrica Push version 1.3.0 and lower (YandexMobileMetricaPush
) and version 2.0.0 and higher (AppMetricaPush
). However, we recommend avoiding this approach because it requires processing push notifications twice and implementing a custom UINotificationCenterDelegate
to invoke handlers from different versions of the AppMetrica Push SDK.
How to make sure that YandexMobileMetricaPush isn't used
Open Podfile.lock
and search YandexMobileMetricaPush
.
From the PODS
section of the Podfile.lock
file, you can understand which dependency refers to YandexMobileMetricaPush
.
PODS:
...
FizzLibarry (10.0.0):
- BuzzLibrary (= 11.0.0)
- YandexMobileMetricaPush (< 2.0.0, >= 1.3.0)
...
If dependencies are set via Xcode
Open the project in Xcode. Make sure that Package Dependencies
don't contain YandexMobileMetricaPush
.
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.
.
└── fizz-library<https://github.com/appmetrica/fizz@10.0.0>
├──buzz-library<https://github.com/appmetrica/buzz@28.0.0>
├── metrica-sdk-push-ios<https://github.com/yandexmobile/metrica-sdk-push-ios@1.3.0>
You can also check the Package.resolved
file for the YandexMobileMetricaPush
dependency.
{
"object": {
"pins": [
//...
{
"package": "YandexMobileMetricaPush",
"repositoryURL": "https://github.com/yandexmobile/metrica-sdk-push-ios",
"state": {
"branch": null,
"revision": "37012eb6d43ad7d9fc32801855f0eb62a53deec7",
"version": "1.3.0"
}
},
//...
]
},
// ...
}
Importing dependencies
import YandexMobileMetricaPush
Replace with:
import AppMetricaPush
import AppMetricaPushLazy // Additional module for lazy push notifications
#import <YandexMobileMetricaPush/YandexMobileMetricaPush.h>
Replace with:
#import <AppMetricaPush/AppMetricaPush.h>
#import <AppMetricaPushLazy/AppMetricaPushLazy.h> // Additional module for lazy push notifications
Renaming the API
Removed the YMP
prefix.
- Renamed the
YMPYandexMetricaPush
interface toAppMetricaPush
.- Removed the
userNotificationCenterDelegate
method. Use theuserNotificationCenterDelegate
property. - Removed the
userNotificationCenterHandler
method. Use theuserNotificationCenterHandler
property.
- Removed the
- Renamed the
YMPUserNotificationCenterDelegate
protocol toUserNotificationCenterDelegate
. - Renamed the
YMPUserNotificationCenterHandling
protocol toUserNotificationCenterHandling
. - Renamed the
YMPYandexMetricaPushEnvironment
enumeration toAppMetricaPushEnvironment
.
Changed the YMP
prefix to AMP
.
- Renamed the
YMPYandexMetricaPush
interface toAMPAppMetricaPush
.- Renamed the
userNotificationCenterDelegate
class method to theuserNotificationCenterDelegate
class property. - Renamed the
userNotificationCenterHandler
class method to theuserNotificationCenterHandler
class.
- Renamed the
- Renamed the
YMPUserNotificationCenterDelegate
protocol toAMPUserNotificationCenterDelegate
. - Renamed the
YMPUserNotificationCenterHandling
protocol toAMPUserNotificationCenterHandling
. - Renamed the
YMPYandexMetricaPushEnvironment
enumeration toAMPAppMetricaPushEnvironment
.