Manual SDK Start
In certain situations, you may want to have full control over when the SDK is initialized.
The manual SDK start
feature allows you to initiate the SDK at any point in your application’s lifecycle.
On this page you will find the steps to control manual start of the Contentsquare Flutter SDK.
Disabling Automatic SDK Initialization
Section titled Disabling Automatic SDK InitializationTo manage SDK start manually, you need to disable automatic initialization on the platform’s native side.
For this you need to modify the AndroidManifest.xml
file of your Android project as well as the Info.plist
file of your iOS project.
Add the com.contentsquare.android.autostart
flag to false
in your AndroidManifest.xml
file.
<application> ... <meta-data android:name="com.contentsquare.android.autostart" android:value="false" /> ...</application>
Add the CSDisableAutostart
key to your Info.plist
. Set it to true
to disable the autostart.
<key>CSDisableAutostart</key><true/>
Manual SDK start
Section titled Manual SDK startYou can control the SDK initialization from your Flutter app code by calling the start
method of the Contentsquare
class.
class UserConsentScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('User Consent'), ), body: Center( child: ElevatedButton( onPressed: () async { await Contentsquare().start();
// Depending on the project configuration in `CS Digital` // you might need to call `optIn` // await Contentsquare().optIn(); }, child: Text('Agree with Terms and Conditions'), ), ), ); }}
After the start
is called the SDK will be initialized and the config will be fetched.
Validate the SDK integration by following the validation steps.
Start method arguments
Section titled Start method argumentsMaskingConfig
Section titled MaskingConfigMaskingConfig
allows you to set the default MaskingConfig
for your entire application. For more dynamic and localized masking, refer to the Session Replay
masking documentation.
void _startContentsquare() async { final maskingConfig = MaskingConfig( maskTexts: true, maskImages: false, );
await Contentsquare().start(maskingConfig: maskingConfig);}