initAppsFlyer method
Initializes AppsFlyer SDK with the dev key from config. Sets the device UUID as the custom user ID. Registers conversion data callback and waits for it to arrive.
Implementation
Future<void> initAppsFlyer() async {
final deviceId = await _getOrCreateDeviceId();
final options = AppsFlyerOptions(
afDevKey: config.appsFlyerDevKey,
appId: config.appsFlyerAppId,
showDebug: config.debugMode,
);
_appsflyerSdk = AppsflyerSdk(options);
_appsflyerSdk!.setCustomerUserId(deviceId);
_appsflyerSdk!.onInstallConversionData((data) {
if (config.debugMode) {
debugPrint('NanoafService: conversion data received: $data');
}
_conversionData = data is Map<String, dynamic>
? data
: (data is Map ? Map<String, dynamic>.from(data) : null);
if (!_conversionDataCompleter.isCompleted) {
_conversionDataCompleter.complete(_conversionData);
}
});
await _appsflyerSdk!.initSdk(
registerConversionDataCallback: true,
registerOnAppOpenAttributionCallback: false,
registerOnDeepLinkingCallback: false,
);
_appsflyerId = await _appsflyerSdk!.getAppsFlyerUID();
if (config.debugMode) {
debugPrint('NanoafService: AppsFlyer initialized, uid=$_appsflyerId');
}
}