update method
Updates the AppsFlyer settings and initializes the SDK if not already initialized.
This method performs the following actions:
- Initializes the AppsFlyer SDK if it hasn't been initialized yet.
- Registers the callback for conversion data if tracking is enabled and the callback hasn't been registered.
- Registers the callback for deep linking if tracking is enabled and the callback hasn't been registered.
\param settings A map containing the settings to update. \param type The type of context update.
Implementation
@override
void update(Map<String, dynamic> settings, ContextUpdateType type) {
/// Check if the SDK has not been initialized
if (!hasInitialized) {
/// Start the AppsFlyer SDK
appsFlyer.startSDK(
onSuccess: () {
/// Set the initialization flag to true on success
hasInitialized = true;
debugPrint("AppsFlyer SDK initialized successfully");
},
onError: (errorCode, errorMessage) {
/// Set the initialization flag to false on error
hasInitialized = false;
debugPrint("Error starting AppsFlyer SDK: $errorCode, $errorMessage");
},
);
}
/// Register callback for conversion data if not already registered and tracking is enabled
if ((trackAttributionData ?? false) && !hasRegisteredInstallCallback) {
registerConversionCallback(); // Register the callback
hasRegisteredInstallCallback = true; // Mark as registered
}
/// Register callback for deep linking if not already registered and tracking is enabled
if ((trackDeepLinks ?? false) && !hasRegisteredDeepLinkCallback) {
registerDeepLinkCallback(); // Register the callback
hasRegisteredDeepLinkCallback = true; // Mark as registered
}
}