### Example Template Definition
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/CustomCodeTemplates.md
Provides a complete example of a template definition, showcasing various argument types including boolean, string, object, action, and file.
```json
"Example template": {
"type": "template",
"arguments": {
"boolArg": {
"type": "boolean",
"value": false
},
"stringArg": {
"type": "string",
"value": "Default"
},
"mapArg": {
"type": "object",
"value": {
"int": {
"type": "number",
"value": 0
},
"string": {
"type": "string",
"value": "Default"
}
}
},
"actionArg": {
"type": "action"
},
"fileArg": {
"type": "file"
}
}
}
```
--------------------------------
### Push Install Referrer
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage.md
Tracks the install referrer information, which is crucial for attribution analysis. Provide source, medium, and campaign details.
```Dart
CleverTapPlugin.pushInstallReferrer("source", "medium", "campaign");
```
--------------------------------
### Attributions API
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage.md
APIs for pushing install referrer information.
```APIDOC
## POST /attributions/installReferrer
### Description
Pushes install referrer information to the CleverTap SDK.
### Method
POST
### Endpoint
/attributions/installReferrer
### Parameters
#### Request Body
- **source** (String) - Required - The source of the install referrer.
- **medium** (String) - Required - The medium of the install referrer.
- **campaign** (String) - Required - The campaign of the install referrer.
### Request Example
```json
{
"source": "google",
"medium": "cpc",
"campaign": "summer_sale"
}
```
### Response
#### Success Response (200)
- **message** (String) - Confirmation message.
#### Response Example
```json
{
"message": "Install referrer pushed successfully."
}
```
```
--------------------------------
### Get All Qualified Campaign Details
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage-Web.md
Fetches details for all campaigns that the user is qualified for.
```Dart
CleverTapPlugin.getAllQualifiedCampaignDetails();
```
--------------------------------
### Add CleverTap Flutter SDK to pubspec.yaml
Source: https://github.com/clevertap/clevertap-flutter/blob/master/README.md
Add the CleverTap Flutter SDK dependency to your project's pubspec.yaml file. Run 'flutter packages get' to install.
```yaml
dependencies:
clevertap_plugin: 4.1.0
```
--------------------------------
### Web Inbox Setup
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage-Web.md
Configure the web inbox by adding a hidden button with a specific ID and optionally using the NotificationButton widget.
```html
```
```dart
NotificationButton(child: Icon(Icons.notifications))
```
--------------------------------
### Get CleverTap Web SDK Version
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage-Web.md
Retrieves the current version of the CleverTap Web SDK.
```Dart
CleverTapPlugin.getSDKVersion()
```
--------------------------------
### Get Last Fetch Timestamp
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage.md
Retrieves the timestamp in milliseconds of the last successful product configuration fetch.
```Dart
CleverTapPlugin.getLastFetchTimeStampInMillis();
```
--------------------------------
### Get Boolean Product Config Value
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage.md
Retrieves a boolean value for a given product configuration key. Provide a default value to be returned if the key is not found.
```Dart
CleverTapPlugin.getProductConfigBoolean("key");
```
--------------------------------
### Get All Inbox Messages
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage-Web.md
Asynchronously retrieve a list of all messages from the web inbox.
```dart
List messages = await CleverTapPlugin.getAllInboxMessages();
```
--------------------------------
### Get All Display Units
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage.md
Retrieves all available display units from CleverTap. Ensure the widget is in a stateful context to update the UI.
```Dart
void onDisplayUnitsLoaded(List displayUnits) {
this.setState(() async {
List displayUnits = await CleverTapPlugin.getAllDisplayUnits();
print("Display Units = " + displayUnits.toString());
});
}
```
--------------------------------
### Import CleverTap Flutter SDK in Dart code
Source: https://github.com/clevertap/clevertap-flutter/blob/master/README.md
Import the CleverTap Flutter SDK into your Dart files to start using its functionalities.
```dart
import 'package:clevertap_plugin/clevertap_plugin.dart';
```
--------------------------------
### Initialize and Fetch Product Configuration
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage.md
Initializes product configuration and fetches the latest configurations from CleverTap. This should be called during app startup.
```Dart
void productConfigInitialized() {
print("Product Config Initialized");
this.setState(() async {
await CleverTapPlugin.fetch();
});
}
```
--------------------------------
### Initialization
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage-Web.md
Initialize the CleverTap SDK with your account credentials and region.
```APIDOC
## Initialization
### Description
Initialize the CleverTap SDK with your account ID, region, target domain, and token.
### Method
`CleverTapPlugin.init(String accountID, String region, String targetDomain, String token)`
### Parameters
#### Path Parameters
- **accountID** (String) - Required - Your CleverTap Account ID.
- **region** (String) - Optional - The region of your CleverTap Dashboard (e.g., 'in1', 'us1', 'sg1', 'aps3', 'mec1').
- **targetDomain** (String) - Optional - The domain of the proxy server.
- **token** (String) - Optional - Mandatory only when using the remote config feature. Your CleverTap Token.
### Request Example
```Dart
CleverTapPlugin.init("CLEVERTAP_ACCOUNT_ID", "CLEVERTAP_REGION", "CLEVERTAP_TARGET_DOMAIN", "CLEVERTAP_TOKEN");
```
```
--------------------------------
### Push Primer Integration
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage.md
Information on integrating the Push Primer for notification permissions.
```APIDOC
## Push Primer Integration
### Description
Follow the [Push Primer integration doc](PushPrimer.md) for detailed instructions on integrating the Push Primer for notification permissions on Android and iOS.
### Method
N/A
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
```
--------------------------------
### Fetch and Activate Product Configuration
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage.md
Fetches the latest product configurations and immediately activates them. This is a convenient method for ensuring the app uses the newest settings.
```Dart
void fetchAndActivate() {
CleverTapPlugin.fetchAndActivate();
}
```
--------------------------------
### Fetch Product Configurations
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage.md
Fetches the latest product configurations from CleverTap. Use `fetchWithMinimumIntervalInSeconds` to control the fetch frequency.
```Dart
void fetch() {
CleverTapPlugin.fetch();
// CleverTapPlugin.fetchWithMinimumIntervalInSeconds(0);
}
```
--------------------------------
### Product Configuration API
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage.md
APIs for managing product configurations, including fetching, activating, and setting defaults.
```APIDOC
## POST /productConfig/fetch
### Description
Fetches the latest product configuration from the server.
### Method
POST
### Endpoint
/productConfig/fetch
### Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **status** (String) - Indicates the status of the fetch operation.
#### Response Example
```json
{
"status": "fetched"
}
```
```
```APIDOC
## POST /productConfig/activate
### Description
Activates the most recently fetched product configuration.
### Method
POST
### Endpoint
/productConfig/activate
### Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **status** (String) - Indicates the status of the activation.
#### Response Example
```json
{
"status": "activated"
}
```
```
```APIDOC
## POST /productConfig/fetchAndActivate
### Description
Fetches and activates the product configuration in a single step.
### Method
POST
### Endpoint
/productConfig/fetchAndActivate
### Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **status** (String) - Indicates the status of the fetch and activate operation.
#### Response Example
```json
{
"status": "fetched_and_activated"
}
```
```
```APIDOC
## POST /productConfig/setMinimumFetchInterval
### Description
Sets the minimum interval in seconds between product config fetches.
### Method
POST
### Endpoint
/productConfig/setMinimumFetchInterval
### Parameters
#### Request Body
- **interval** (Integer) - Required - The minimum interval in seconds.
### Request Example
```json
{
"interval": 3600
}
```
### Response
#### Success Response (200)
- **message** (String) - Confirmation message.
#### Response Example
```json
{
"message": "Minimum fetch interval set successfully."
}
```
```
```APIDOC
## GET /productConfig/boolean
### Description
Retrieves a boolean value for a given product config key.
### Method
GET
### Endpoint
/productConfig/boolean
### Parameters
#### Query Parameters
- **key** (String) - Required - The key for the boolean product configuration.
### Request Example
None
### Response
#### Success Response (200)
- **value** (Boolean) - The boolean value associated with the key.
#### Response Example
```json
{
"value": true
}
```
```
```APIDOC
## GET /productConfig/lastFetchTimestamp
### Description
Retrieves the timestamp in milliseconds of the last product config fetch.
### Method
GET
### Endpoint
/productConfig/lastFetchTimestamp
### Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **timestamp** (Long) - The timestamp in milliseconds.
#### Response Example
```json
{
"timestamp": 1678886400000
}
```
```
--------------------------------
### Get All Unread Inbox Messages
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage-Web.md
Asynchronously retrieve a list of all unread messages from the web inbox.
```dart
List messages = await CleverTapPlugin.getUnreadInboxMessages();
```
--------------------------------
### Get CleverTap ID
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage-Web.md
Retrieve the unique CleverTap ID for the current user. This is an asynchronous operation.
```dart
CleverTapPlugin.getCleverTapID().then((clevertapId) {})
```
--------------------------------
### Initialize CleverTap Plugin
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage-Web.md
Initialize the CleverTap plugin with your account ID, region, target domain, and token. The token is mandatory for remote config.
```dart
CleverTapPlugin.init("CLEVERTAP_ACCOUNT_ID", "CLEVERTAP_REGION", "CLEVERTAP_TARGET_DOMAIN","CLEVERTAP_TOKEN");
```
--------------------------------
### Get CleverTap Account ID
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage-Web.md
Retrieve the CleverTap Account ID configured for the plugin. This is an asynchronous operation.
```dart
CleverTapPlugin.getAccountID().then((accountId) {})
```
--------------------------------
### Add App-Level Dependencies
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Integrate-Android.md
Include these implementations in your `app/build.gradle` file. Some are mandatory for specific features like App Inbox or optional for media playback.
```groovy
implementation 'com.google.firebase:firebase-messaging:23.4.1'
implementation 'androidx.core:core:1.3.0'
implementation 'androidx.fragment:fragment:1.3.6'
//MANDATORY for App Inbox
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.viewpager:viewpager:1.0.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'
//For CleverTap Android SDK v3.6.4 and above add the following -
implementation 'com.android.installreferrer:installreferrer:2.2'
//Optional ExoPlayer/AndroidX Media3 Libraries for Audio/Video Inbox Messages. Audio/Video messages will be dropped without these dependencies
implementation 'com.google.android.exoplayer:exoplayer:2.19.1'
implementation 'com.google.android.exoplayer:exoplayer-hls:2.19.1'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.19.1'
```
--------------------------------
### Get Inbox Message by ID
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage-Web.md
Asynchronously retrieve a specific inbox message using its unique message ID.
```dart
var messageForId = await CleverTapPlugin.getInboxMessageForId(messageId);
```
--------------------------------
### Activate Product Configuration
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage.md
Activates the most recently fetched product configuration, making its values available for use in the app.
```Dart
void activate() {
CleverTapPlugin.activate();
}
```
--------------------------------
### Get Total Unread Inbox Message Count
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage-Web.md
Asynchronously retrieve the count of unread messages in the web inbox.
```dart
int unread = await CleverTapPlugin.getInboxMessageUnreadCount();
print("Unread count = " + unread.toString());
```
--------------------------------
### Configure Application Class in AndroidManifest.xml
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Integrate-Android.md
If your project does not have an existing Application class, add this entry to your `AndroidManifest.xml` to use CleverTap's Application class.
```xml
```
--------------------------------
### Get Total Inbox Message Count
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Usage-Web.md
Asynchronously retrieve the total number of messages available in the web inbox.
```dart
int total = await CleverTapPlugin.getInboxMessageCount();
print("Total count = " + total.toString());
```
--------------------------------
### Import CleverTap Headers (Swift)
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Integrate-iOS.md
Import the CleverTap SDK and plugin headers in your AppDelegate file for Swift projects.
```swift
import CleverTapSDK
import clevertap_plugin
```
--------------------------------
### Get All CleverTap Variables
Source: https://github.com/clevertap/clevertap-flutter/blob/master/doc/Variables.md
Retrieves all fetched CleverTap variables as a map. This is useful for accessing multiple variable values at once.
```dart
this.setState(() async {
Map