Native Application with Flutter Components

If your app is native but is using Flutter components, use this guide to be able to track your entire app.

This guide assumes you have a prior knowledge of integrating Flutter components into your native app. If you don't, use this official Flutter documentation to learn how this can be done.

In the pubspec.yaml, please add the Pendo plugin under the dependencies section:
pendo_sdk: ^2.10.0 (please make sure you are using the latest version)
In the terminal run: flutter pub get
In your native app folder, run: pod install

 

iOS

After that you will need to init the SDK in the native code and register the plugin:
SDK initialization (sample code):

Swift

import UIKit
import
Flutter
import FlutterPluginRegistrant
import Pendo
class AppDelegate: FlutterAppDelegate {
lazy var flutterEngine = FlutterEngine(name: "my flutter engine")
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
 //Initializing The SDK
 let key = "YOUR KEY"
 let params = PendoInitParams()
 params.visitorId = "flutterV1"
 params.accountId = "flutterV1"
 PendoManager.shared().initSDK(key, initParams: params)
 // Runs the default Dart entrypoint with a default Flutter route.
 flutterEngine.run();
 // Used to connect plugins (only if you have plugins with iOS platform code).
 GeneratedPluginRegistrant.register(with: self.flutterEngine);
//Registering the Pendo Plugin
PendoFlutterPlugin.registerWithRegistry(self.flutterEngine)
 return super.application(application, didFinishLaunchingWithOptions: launchOptions);
 }

To access the PendoFlutterPlugin.h please include it in the Bridging-Header.h of your app
#import "PendoFlutterPlugin.h"

Obj-C

 
@import Flutter;
 @import Pendo;
 #import "PendoFlutterPlugin.h"
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 PendoInitParams *initParams = [[PendoInitParams alloc] init];
 [initParams setVisitorId:@"flutterV1"];
 [initParams setVisitorId:@"flutterV1"];
 [[PendoManager sharedManager] initSDK:@"YOUR_KEY" initParams: initParams];
 FlutterEngine *flutterEngine = [[FlutterEngine alloc] initWithName:@"my flutter engine"];
 [flutterEngine run];
 [PendoFlutterPlugin registerWithRegistry:flutterEngine];
 return YES;
}

Now you should be able to use Pendo track event from the Dart side:

 
import 'package:pendo_sdk/pendo_sdk.dart';

PendoFlutterPlugin.track('Track Event Send', {})}

 

Android

Kotlin

1. Add Pendo Repository to build.gradle:

 
repositories {
    maven {
        url "https://software.mobile.pendo.io/artifactory/androidx-release"
    }
    mavenCentral()
}


2. Add Pendo a dependency to 

 
dependencies {
    implementation group:'sdk.pendo.io' , name:'pendoIO', version:'2.10.+', changing:true
 }


3. Add the following activity to the application AndroidManifest.xml in the tag:

 
<activity android:name="sdk.pendo.io.activities.PendoGateActivity" android:launchMode="singleInstance">
  <intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="PENDO-SCHEME"/>
  </intent-filter>
 </activity>


4. After that you will need to init the SDK from the native and register the plugin:
SDK initialisation(sample code):

 
package io.tsh.flutterloginembedding

import android.app.Application
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.embedding.engine.FlutterEngineCache
import io.flutter.embedding.engine.dart.DartExecutor
import io.flutter.plugins.GeneratedPluginRegistrant
import sdk.pendo.io.Pendo
import sdk.pendo.io.Pendo.PendoInitParams
import sdk.pendo.io.Pendo.PendoOptions
import java.util.*

class App : Application() {

    companion object {
        const val FLUTTER_ENGINE_ID = "newLoginEngine"
    }

    override fun onCreate() {
        super.onCreate()
        // Instantiate a FlutterEngine.
        val flutterEngine = FlutterEngine(this)

        // Start executing Dart code to pre-warm the FlutterEngine.
        flutterEngine.dartExecutor.executeDartEntrypoint(
            DartExecutor.DartEntrypoint.createDefault()
        )

        // Cache the FlutterEngine to be used by FlutterActivity.
        FlutterEngineCache
            .getInstance()
            .put(FLUTTER_ENGINE_ID, flutterEngine)

        val pendoParams = PendoInitParams()
        pendoParams.accountId = "David 123"
        pendoParams.visitorId = "David 123"

        // send Visitor Level Data
        val userData = HashMap<String, Any>()
        userData["age"] = 27
        userData["country"] = "USA"
        pendoParams.visitorData = userData

        //send Account Level Data
        val accountData = HashMap<String, Any>()
        accountData["Tier"] = 1
        accountData["Size"] = "Enterprise"
        pendoParams.accountData = accountData

        val pendoAppKey = "PENDO_APP_KEY"

        Pendo.initSDK(
            this,
            pendoAppKey,
            pendoParams)


        // Used to connect plugins 
        GeneratedPluginRegistrant.registerWith(flutterEngine)
    }
}