Additional Yandex Mobile Ads steps - cleveradssolutions/CAS-ReactNative GitHub Wiki
Yandex App Metrics will be added along with Yandex Ads SDK.
[!IMPORTANT]
You should take into account some features of the AppMetrica library during initialization.
For more information, see Features of the AppMetrica library.
[!NOTE]
The CAS SDK automatically initializes the Yandex Mobile Ads SDK, and the Yandex Mobile Ads SDK activates AppMetrica for its operation. Additionally, the CAS SDK automatically initializes Firebase Analytics for collecting ad_impression events.
When the CAS SDK initializes the Yandex Mobile Ads SDK before initializing Firebase Analytics, it leads to a crash in the app.
When using Firebase Performance Monitoring in Firebase version 31.0.0+, activate FirebaseApp for all processes, including the AppMetrica SDK process. In React Native, Firebase Analytics initializes automatically before your code launches, so you will not see this crash, but if you want to do custom native init flow (or you disabled automatic analytics initialization) you should initialize Firebase SDK before CAS SDK and AppMetrica SDK
React Native:
// <project-root>/firebase.json
{
"react-native": {
"analytics_auto_collection_enabled": false
}
}
import { firebase } from '@react-native-firebase/analytics';
import { CAS } from 'react-native-cas';
// ...
await firebase.analytics().setAnalyticsCollectionEnabled(true);
const { manager, result } = await CAS.buildManager(...);
Android Native (If you use native init flow):
class YourApplication extends Application {
@Override
public void onCreate() {
super.onCreate()
// if app use FirebaseApp then init it first for all processes
FirebaseApp.initializeApp(this)
// if app use AppMetrica then activate it for all processes
AppMetricaConfig config = AppMetricaConfig.newConfigBuilder(API_KEY).build();
AppMetrica.activate(this, config);
if (CASUtilities.isMainProcess(this)) {
// Before user finishes the consent flow
// Initializing third-party SDKs for main process only
}
// Initialize CAS
CAS.buildManager()
.withCompletionListener(config -> {
// After the user finishes the consent flow
// Initializing third-party SDKs for all processes
if (CASUtilities.isMainProcess(this)) {
// Initializing thrid-party SDKs for main process only
}
}
.initialize();
}
}
[!TIP]
- Se also AppMetrica Error descriptions on developer docs.
- Read more about CAS initialization.
Excluding geo from the list of dependencies
If you need to disable geo, for example, for certain app categories to meet Google Play policies, read how exclude location dependencies on AppMetrica developer docs.