Flutter SDK - Configuration Methods Reference
This document provides a comprehensive reference for all configuration options available in the Singular SDK for Flutter applications. The SingularConfig object allows you to customize the SDK's behavior, including tracking settings, attribution options, privacy controls, and more. Each configuration method is presented with a description, signature, and practical usage examples.
clipboardAttribution
SingularConfig.clipboardAttribution Property
Enables clipboard attribution for the SDK. When enabled, the SDK will check the device clipboard for attribution links during initialization.
Signature
bool clipboardAttribution = false;
Usage Example
// Enable clipboard attribution
config.clipboardAttribution = true;
collectOAID
SingularConfig.collectOAID Property
Enables collection of OAID (Open Anonymous Device Identifier) on supported Android devices. This is an alternative identifier used in some regions, particularly in China.
Signature
bool collectOAID = false;
Usage Example
// Enable OAID collection
config.collectOAID = true;
conversionValueUpdatedCallback
SingularConfig.conversionValueUpdatedCallback Property
Sets a callback function to be called when the SKAdNetwork conversion value is updated. This is specific to iOS and allows you to react to conversion value changes.
Signature
ConversionValueUpdatedCallback? conversionValueUpdatedCallback;
Usage Example
// Set conversion value updated callback
config.conversionValueUpdatedCallback = (int conversionValue) {
print("Conversion value updated to: $conversionValue");
// Update UI or take other actions based on the new conversion value
};
conversionValuesUpdatedCallback
SingularConfig.conversionValuesUpdatedCallback Property
Sets a callback function to be called when the SKAdNetwork 4.0 conversion values are updated. This is specific to iOS 16.1+ and allows you to react to changes in fine, coarse, and lock values.
Signature
ConversionValuesUpdatedCallback? conversionValuesUpdatedCallback;
Usage Example
// Set conversion values updated callback for SKAdNetwork 4.0
config.conversionValuesUpdatedCallback = (int conversionValue, int coarse, bool lock) {
print("Conversion values updated - Fine: $conversionValue, Coarse: $coarse, Lock: $lock");
// Update UI or take other actions based on the new conversion values
};
customSdid
SingularConfig.customSdid Property
Enterprise Feature: Sets a custom SDID (Singular Device ID). This allows you to provide your own device identifier instead of using the one generated by Singular.
Signature
String? customSdid;
Usage Example
// Set custom SDID
config.customSdid = "custom-device-id-12345";
customUserId
SingularConfig.customUserId Property
Sets a custom user ID during SDK initialization. This allows you to associate Singular data with your own user identification system from the start.
Signature
String? customUserId;
Usage Example
// Set custom user ID
config.customUserId = "user_123456";
deviceAttributionCallback
SingularConfig.deviceAttributionCallback Property
BETA Feature: Sets a callback function to be called when device attribution data is available. This allows you to access attribution data as soon as it's available.
Signature
DeviceAttributionCallback? deviceAttributionCallback;
Usage Example
// Set device attribution callback
config.deviceAttributionCallback = (Map attributionData) {
print("Attribution data received: $attributionData");
// Access specific attribution parameters
final campaign = attributionData["campaign"];
final source = attributionData["source"];
final adSet = attributionData["adSet"];
// Update UI or take actions based on attribution data
if (campaign != null) {
showCampaignSpecificContent(campaign);
}
};
didSetSdidCallback
SingularConfig.didSetSdidCallback Property
Enterprise Feature: Sets a callback function to be called when the SDID (Singular Device ID) is set. This allows you to be notified when the custom SDID has been successfully set.
Signature
SdidAccessorCallback? didSetSdidCallback;
Usage Example
// Set custom SDID
config.customSdid = "custom-device-id-12345";
// Set callback for when SDID is set
config.didSetSdidCallback = (String sdid) {
print("SDID was set: $sdid");
// Perform any actions needed after SDID is set
};
enableLogging
SingularConfig.enableLogging Property
Enables detailed logging for the SDK. When enabled, the SDK will output detailed logs that can help with debugging.
Signature
bool enableLogging = false;
Usage Example
// Enable logging for debugging
config.enableLogging = true;
espDomains
SingularConfig.espDomains Property
Sets the ESP (Email Service Provider) domains for email attribution. This allows you to specify which email domains should be considered for attribution.
Signature
List espDomains = [];
Usage Example
// Set ESP domains for email attribution
config.espDomains = [
"mailchimp.com",
"sendgrid.net",
"campaign-monitor.com"
];
facebookAppId
SingularConfig.facebookAppId Property
Sets the Facebook App ID for Facebook attribution. This allows the SDK to attribute installs and events from Facebook campaigns.
Signature
String? facebookAppId;
Usage Example
// Set Facebook App ID for attribution
config.facebookAppId = "123456789012345";
imei
SingularConfig.imei Property
Sets the IMEI (International Mobile Equipment Identity) for the device. This is typically used in markets where IMEI is a common identifier for attribution.
Signature
String? imei;
Usage Example
// Set IMEI (only if you have proper permission to access it)
config.imei = "123456789012345";
limitDataSharing
SingularConfig.limitDataSharing Property
Sets the data sharing limitation status during SDK initialization. Use this property to limit data sharing based on user consent or privacy requirements.
Signature
bool? limitDataSharing;
Usage Example
// Get user consent status
bool hasUserConsent = getUserConsentStatus();
// Set data sharing limitation based on consent
config.limitDataSharing = !hasUserConsent;
limitedIdentifiersEnabled
SingularConfig.limitedIdentifiersEnabled Property
Enables or disables the use of limited identifiers. This option affects how the SDK collects and uses device identifiers for tracking and attribution.
Signature
bool limitedIdentifiersEnabled = false;
Usage Example
// Enable limited identifiers mode
config.limitedIdentifiersEnabled = true;
logLevel
SingularConfig.logLevel Property
Sets the log level for the SDK. This controls the verbosity of logs generated by the SDK. Default value is -1 (no logging). Common values are: 0 (error), 1 (warning), 2 (info), 3 (debug), 4 (verbose).
Signature
int logLevel = -1;
Usage Example
// Set log level to debug
config.logLevel = 3;
manualSkanConversionManagement
SingularConfig.manualSkanConversionManagement Property
Enables manual management of SKAdNetwork conversion values. When enabled, the SDK will not automatically update conversion values, allowing you to control them manually.
Signature
bool manualSkanConversionManagement = false;
Usage Example
// Enable manual SKAdNetwork conversion management
config.manualSkanConversionManagement = true;
pushNotificationsLinkPaths
SingularConfig.pushNotificationsLinkPaths Property
Sets the paths to look for deep links in push notification payloads. This helps the SDK find and process attribution links in push notifications.
Signature
List<List<String>> pushNotificationsLinkPaths = [[]];
Usage Example
// Set push notification link paths
config.pushNotificationsLinkPaths = [
["data", "deeplink"],
["notification", "data", "url"],
["custom", "link"]
];
sdidReceivedCallback
SingularConfig.sdidReceivedCallback Property
Enterprise Feature: Sets a callback function to be called when the SDID (Singular Device ID) is received. This allows you to access the SDID as soon as it's available.
Signature
SdidAccessorCallback? sdidReceivedCallback;
Usage Example
// Set callback for when SDID is received
config.sdidReceivedCallback = (String sdid) {
print("SDID received: $sdid");
// Store or use the SDID as needed
storeDeviceIdentifier(sdid);
};
sessionTimeout
SingularConfig.sessionTimeout Property
Sets the session timeout in seconds. This determines how long a user session lasts after the app goes to the background. Default value is -1, which uses the SDK's default timeout (60 seconds).
Signature
double sessionTimeout = -1;
Usage Example
// Set session timeout to 2 minutes
config.sessionTimeout = 120;
shortLinkResolveTimeOut
SingularConfig.shortLinkResolveTimeOut Property
Sets the timeout in seconds for resolving short links. This determines how long the SDK will wait for a short link to resolve before continuing with initialization. Default value is 10 seconds.
Signature
double shortLinkResolveTimeOut = 10.0;
Usage Example
// Set short link resolve timeout to 15 seconds
config.shortLinkResolveTimeOut = 15.0;
singularLinksHandler
SingularConfig.singularLinksHandler Property
Sets a callback function to handle deep links processed by Singular. This allows your app to respond to deep links used in attribution.
Signature
SingularLinksHandler? singularLinksHandler;
Usage Example
// Set singular links handler
config.singularLinksHandler = (SingularLinkParams params) {
// Check if we have a deep link
if (params.deeplink != null) {
print("Deep link received: ${params.deeplink}");
// Navigate based on the deep link
navigateToScreen(params.deeplink!);
}
// Check if this is a deferred deep link
if (params.isDeferred == true) {
print("This is a deferred deep link");
}
// Access passthrough parameters
if (params.passthrough != null) {
print("Passthrough data: ${params.passthrough}");
}
// Access all URL parameters from the OpenURL/Deeplink. Does not work with Deferred Deep Links.
if (params.urlParameters != null) {
print("URL parameters: ${params.urlParameters}");
}
};
skAdNetworkEnabled
SingularConfig.skAdNetworkEnabled Property
Enables or disables SKAdNetwork support. This is specific to iOS and controls whether the SDK will use Apple's SKAdNetwork for attribution. Default value is true.
Signature
bool skAdNetworkEnabled = true;
Usage Example
// Disable SKAdNetwork support if needed
config.skAdNetworkEnabled = false;
waitForTrackingAuthorizationWithTimeoutInterval
SingularConfig.waitForTrackingAuthorizationWithTimeoutInterval Property
Sets the timeout interval in seconds to wait for the user's tracking authorization response on iOS 14+. This determines how long the SDK will wait for the ATT prompt response before continuing with initialization. Default value is 0, which means the SDK won't wait for the ATT prompt response.
Signature
int waitForTrackingAuthorizationWithTimeoutInterval = 0;
Usage Example
// Wait up to 5 seconds for ATT prompt response
config.waitForTrackingAuthorizationWithTimeoutInterval = 5;
withGlobalProperty
SingularConfig.withGlobalProperty Method
Sets a global property during SDK initialization. This property will be sent with all events tracked by the SDK. This is a method rather than a property, allowing for chained configuration.
Signature
void withGlobalProperty(String key, String value, bool overrideExisting)
Usage Example
// Add global properties
config.withGlobalProperty("app_version", "1.2.3", true);
config.withGlobalProperty("user_type", "free", true);
Complete Configuration Example
Comprehensive SDK Configuration
The following example demonstrates how to create a comprehensive configuration by setting multiple configuration properties and methods together.
Complete Example
SingularConfig config = new SingularConfig('SDK KEY', 'SDK SECRET');
config.waitForTrackingAuthorizationWithTimeoutInterval = 60;
config.customUserId = "user_123456"; // Set a custom user ID for tracking
config.withGlobalProperty("key1", "value1", true);
config.limitDataSharing = false; // Allow data sharing (set to true for compliance if needed)
config.facebookAppId = "123456789012345"; // Optional: For Facebook integration
config.singularLinksHandler = (SingularLinkParams params) {
print('Received deferred deeplink: ');
deeplinkParams['deeplink'] = params.deeplink;
deeplinkParams['passthrough'] = params.passthrough;
deeplinkParams['isDeferred'] = params.isDeferred;
};
Singular.start(config);