Flutter SDK

Flutter Integration Guide

The Uptick Ads Flutter SDK allows seamless integration of personalized offers into your Flutter applications. Inspired by our Android integration guide, this SDK provides a simple yet powerful way to render dynamic, context-sensitive offers with minimal configuration—ensuring a smooth user experience.


Features

  • Dynamic Offer Rendering: Display offers tailored to specific contexts and user data.
  • Multiple Placements: Supports predefined placements such as order_confirmation, order_status, and survey.
  • Error Handling and Callbacks: Built-in callbacks for handling errors and receiving render-type events.
  • Automatic Flow Management: Automatically fetches and updates offers based on integration details.
  • Cross-Platform Support: Works on both Android and iOS.
  • Example App Included: A sample app demonstrates SDK integration and usage.

Requirements

  • Android: Minimum API Level 26 (Android 8.0 Oreo)
  • iOS: Minimum version 11.0
  • Flutter: Compatible with Flutter 3

Installation

1. Add Dependency

Add the following lines to your pubspec.yaml file:

 flutter pub add uptick_ads

Then, run:

flutter pub get

2. Import the SDK

In your Dart files, import the Uptick widget:

import 'package:uptick_ads/screens/uptick_widget.dart';

3. Platform-Specific Configuration

Android

Update your android/app/build.gradle to ensure the minimum SDK version is set correctly:

android {
    defaultConfig {
        minSdkVersion 26 // Minimum Android version supported
    }
}

iOS

Ensure your ios/Podfile contains the following configuration:

platform :ios, '11.0' // Minimum iOS version supported

Usage

Flutter Integration Guide

The Uptick Ads Flutter SDK provides a widget-based integration to render personalized offers. Follow these steps to integrate the widget and configure callbacks.

1. Displaying Offers

Simply insert the UptickWidget in your widget tree. The widget requires an integrationId and a placement parameter:

import 'package:uptick_ads/screens/uptick_widget.dart';

UptickWidget(
  integrationId: "AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE",
  placement: "order_confirmation",
)

2. Configuring Callbacks

To handle errors and adjust UI based on the type of offer (e.g. popup vs. inline), configure the widget’s callback functions:

UptickWidget(
  integrationId: "AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE",
  placement: "order_confirmation",
  onRenderTypeReceived: (renderType) {
    // Customize UI based on render type:
    // For example, if renderType is "popup", you might choose a full-screen container.
    print("Render Type: $renderType");
  },
  onError: (errorMessage) {
    // Handle errors, e.g. by showing a Snackbar or logging the error.
    print("Error: $errorMessage");
  },
)

3. Automatic Flow Management

The widget automatically fetches and updates offers based on your integration details, ensuring that content remains dynamic and responsive.


Example Usage

Below is a complete example of integrating the Uptick Ads Flutter SDK in a Flutter app:

import 'package:flutter/material.dart';
import 'package:uptick_ads/screens/uptick_widget.dart';

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Uptick Plugin Example'),
      ),
      body: Center(
        child: UptickWidget(
          integrationId: "AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE",
          placement: "order_status",
          onRenderTypeReceived: (renderType) {
            // Customize layout based on render type if needed.
          },
          onError: (errorMessage) {
            ScaffoldMessenger.of(context).showSnackBar(
              SnackBar(content: Text("Error: $errorMessage")),
            );
          },
        ),
      ),
    );
  }
}

Running the Example App

Follow these steps to run the example application provided in the repository:

  1. Clone the Repository:
   git clone https://github.com/uptick-ads/flutter-sdk
  1. Navigate to the Example App:
   cd example
  1. Install Dependencies:
   flutter pub get
  1. Run the App:
   flutter run

Plugin Details

This plugin supports both Android and iOS platforms. In your pubspec.yaml, the plugin configuration should look like:

flutter:
  plugin:
    platforms:
      android:
        package: com.example.uptick_ads
        pluginClass: FlutterUptickPlugin
      ios:
        pluginClass: FlutterUptickPlugin

Troubleshooting Tips

  • Layout Issues: Verify that the UptickWidget is properly integrated into your widget tree and that the correct integration ID is provided.
  • Error Handling: Use the onError callback to capture any issues during offer rendering. Check network connectivity and integration credentials.
  • Support: If problems persist, please refer to our documentation or contact technical support via our GitHub repository.

License

This SDK is released under the MIT License.


Support

If issues persist, reach out to our technical support team for further assistance.