Marigold Mobile Flutter SDK

The Marigold Mobile Flutter SDK enables seamless integration of Marigold’s messaging and analytics capabilities into Flutter applications for both Android and iOS platforms. This plugin serves as a bridge between your Flutter app and the native Marigold SDKs.

View on pub.dev


Installation

Add the plugin to your pubspec.yaml:

dependencies:
  marigold_mobile_flutter_sdk: <latest_version>

Then run flutter pub get

iOS Setup

Follow the steps below to configure the Marigold Flutter SDK on iOS.

Requires Flutter 3.44 or higher, iOS 17.6 or higher, and Swift Package Manager (SPM) enabled in the consuming app. CocoaPods integration is no longer supported. Marigold is resolved automatically through the plugin; you do not need to add it separately in Xcode.

1. Set the Minimum iOS Version

Open ios/Runner.xcworkspace in Xcode and set the iOS Deployment Target to 17.6 or higher for Runner and any test or extension targets using Marigold.

Ensure SPM is enabled in your app's pubspec.yaml:

flutter:
  config:
    enable-swift-package-manager: true

Run flutter pub get, then flutter build ios --config-only --simulator --debug. Flutter adds SPM integration to the app's Xcode project. Commit the resulting project and scheme changes.

To run on a simulator, use flutter devices to find its ID, then run flutter run -d <SIMULATOR_ID>. With Flutter 3.44 and Xcode 27 on Apple Silicon, the generic flutter build ios --simulator command fails in Flutter's architecture check; see the example build instructions for the xcodebuild workaround.

Existing apps can use SPM for this plugin while Flutter continues to use CocoaPods for other plugins that require it. Before removing CocoaPods from the host app entirely, migrate any manually added pods and confirm all plugins support SPM. Follow the Flutter app migration guide.

2. Configure AppDelegate.swift

For apps using the UIKit scene lifecycle, update AppDelegate.swift to initialize Marigold and register plugins with the implicit Flutter engine:

import Flutter
import Marigold
import UIKit

@main
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    let marigold = Marigold()
    try! marigold.startEngine("<SDK_KEY>")

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

  func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
    GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
  }
}

Ensure your Runner uses the scene lifecycle. The example's Info.plist shows the required UIApplicationSceneManifest configuration.

3. Info.plist Configuration

Ensure your Info.plist file includes any required configurations (e.g., permissions for push notifications, network access, etc.). Example for network permission:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

Android Setup

Follow these steps to configure the Marigold Flutter SDK in your Android project.


Android build configuration

Compile against Android API 37 with a compatible Android Gradle Plugin and Gradle wrapper. The example app contains a working configuration. If your app uses AGP 9 with Flutter's legacy Kotlin setup, add these settings to its android/gradle.properties:

android.builtInKotlin=false
android.newDsl=false

The SDK module works with either Kotlin mode. Apps already using built-in Kotlin do not need to disable it for this SDK.

Add the Marigold Maven repository to your host app's Android dependency repositories:

maven { url = uri("https://github.com/sailthru/maven-repository/raw/master/") }

1. Set Minimum SDK Version

In android/app/build.gradle, ensure the minimum SDK version is at least 23:

defaultConfig {
  minSdkVersion 23
  // other settings...
}

2. Add Internet Permission

Open android/app/src/main/AndroidManifest.xml and add the following line inside the

<uses-permission android:name="android.permission.INTERNET"/>

3. Call startEngine()

override fun onCreate() {
    super.onCreate()

    Marigold().startEngine(this, "<SDK_KEY>")
}

4. In order to get push working you'll also need to add the google-services.json.

Place your google-services.json file in:

android/app/google-services.json

Clean and Build

After setup, clean and rebuild your project:

flutter clean
flutter pub get
flutter run