• Platforms
  • Partners
  • Forums
  • 日本語
  • TLC Tealium Learning Center Tealium Learning
    Community
  • Discussions & Ideas Dicussions & Ideas
  • Product Guides Product Guides
  • Knowledge Base Knowledge Base
  • Developer Docs Developer Docs
  • Education Education
  • TLC Blog TLC Blog
  • Support Desk Support Desk
  • CDH Customer Data Hub Customer Data Hub
  • Mobile
  • Getting Started
    • Overview
    • Quick Start Guide
    • Mobile Concepts
    • Client-Side
    • Server-Side
    • Tracking Webviews
    • Data Layer
    • Consent Management
    • Event Batching
    • User Location and Geofencing
    • Media Tracking
    • Deep Links
    • Timed Events
    • Trace
    • Hosted Data Layer
    • Adobe Visitor Service Module
    • Feature Comparison
    • Troubleshooting
  • Remote Commands
    • Overview
    • How It Works
    • Integrations
      • Adjust
      • AppsFlyer
      • Branch
      • Braze
      • Contentsquare
      • Facebook
      • Firebase
      • Kochava
      • Usabilla
  • Android (Java)
    • Overview
    • Install
    • Track
    • Data Layer
    • Data Management
    • Consent Management
    • Module List
      • Ad Identifier Module
      • Crash Reporter Module
      • Install Referrer Module
      • Lifecycle Tracking Module
      • Location Module
      • Optimizely X Tracking Module
    • Android TV
    • Android Wear
    • API Reference
      • ConsentManager
      • DataSources
      • Lifecycle
      • Tealium
      • Tealium.Config
      • TealiumLocation
    • Release Notes
  • Android (Kotlin)
    • Overview
    • Install
    • Track
    • Data Layer
    • Consent Management
    • Identity Resolution
    • Module List
      • Ad Identifier Module
      • AutoTracking Module
      • AdobeVisitorService Module
      • Collect Module
      • Collectors Module
      • Crash Reporter Module
      • In-App Purchase Module
      • Install Referrer Module
      • Lifecycle Tracking Module
      • Location Manager Module
      • Media Module
      • RemoteCommands Module
      • Tag Management Dispatcher Module
      • Visitor Service Module
    • Android TV
    • API Reference
      • ConsentCategory
      • ConsentManager
      • CurrentVisit
      • DataLayer
      • Lifecycle
      • LocationManager
      • Media
      • Tealium
      • TealiumConfig
      • VisitorProfile
      • VisitorService
    • Release Notes
  • Cordova 1.x
    • Overview
    • Install
    • Track
    • Data Management
    • Module List
      • Ad Identifier Module
      • Crash Reporter Module
      • Install Referrer Module
    • API Reference
    • Release Notes
  • Cordova 2.x
    • Overview
    • Install
    • Track
    • API Reference
    • Release Notes
  • Flutter 1.x
    • Overview
    • Install
    • Track
    • Consent Management
    • Data Management
    • API Reference
    • Release Notes
  • Flutter 2.x
    • Overview
    • Install
    • Track
    • Consent Management
    • Data Management
    • API Reference
      • Tealium
      • TealiumConfig
      • VisitorProfile
    • Release Notes
  • iOS (Objective-C)
    • Overview
    • Install
    • Track
    • Data Layer
    • Data Management
    • Consent Management
    • Tag Management
    • Module List
      • Lifecycle Tracking Module
    • tvOS
    • watchOS
    • API Reference
    • Release Notes
  • iOS (Swift) 1.x
    • Overview
    • Install
    • Track
    • Data Layer
    • Data Management
    • App Extensions
    • Identity Resolution
    • Consent Management
    • Modules
    • Module List
      • AppData Module
      • Attribution Module
      • AutoTracking Module
      • Collect Module
      • Connectivity Module
      • CrashReporter Module
      • DataSource Module
      • DefaultStorage Module
      • Delegate Module
      • DeviceData Module
      • DispatchQueue Module
      • FileStorage Module
      • Lifecycle Module
      • Location Module
      • Logger Module
      • PersistentData Module
      • RemoteCommands Module
      • TagManagement Module
      • VisitorService Module
      • VolatileData Module
    • Feature Comparison
    • Working with Objective-C
    • API Reference
      • TealiumConfig
      • TealiumConsentCategories
      • TealiumConsentManagerDelegate
      • TealiumConsentManager
      • TealiumInstanceManager
      • TealiumPersistentData
      • TealiumVolatileData
      • Tealium
    • Release Notes
  • iOS (Swift) 2.x
    • Overview
    • Install
    • Track
    • Data Layer
    • Consent Management
    • App Extensions
    • Identity Resolution
    • Modules
    • Module List
      • AppData Module
      • AdobeVisitorService Module
      • Attribution Module
      • AutoTracking Module
      • Collect Module
      • Connectivity Module
      • CrashReporter Module
      • DeviceData Module
      • In-App Purchase Module
      • Lifecycle Module
      • Location Module
      • Media Module
      • RemoteCommands Module
      • TagManagement Module
      • VisitorService Module
    • Working with Objective-C
    • API Reference
      • LocationModule
      • MediaSession
      • Tealium
      • TealiumConfig
      • TealiumConsentCategories
      • TealiumConsentManager
      • TealiumDataLayer
      • TealiumInstanceManager
    • Release Notes
  • NativeScript
    • Overview
    • Install
    • Track
    • API Reference
      • Tealium
      • TealiumConfig
    • Release Notes
  • React Native 1.x
    • Overview
    • Install
    • Track
    • API Reference
    • Release Notes
  • React Native 2.x
    • Overview
    • Install
    • Track
    • Location Module
    • API Reference
    • Release Notes
  • Unity 1.x
    • Overview
    • Install
    • Track
    • API Reference
  • Unity 2.x
    • Overview
    • Install
    • Track
    • API Reference
  • Xamarin 1.x
    • Overview
    • Install
    • Track
    • Data Management
    • Consent Management
    • API Reference
    • Release Notes
  • Xamarin 2.x
    • Overview
    • Install
    • Track
    • Data Layer
    • Consent Management
    • API Reference
    • Release Notes
  • Web
  • Getting Started
    • Overview
    • Quick Start Guide
    • Web Concepts
    • Data Layer
      • An Introduction to the Data Layer
      • How the Data Layer Works for Websites
      • Data Layer Best Practices
      • Definitions
        • Retail
        • Publisher
        • Hotel
        • Travel
        • Basic Video Tracking
  • Adobe Launch
    • Overview
    • Install
    • Data Layer
  • AMP
    • Overview
    • Install
    • Track
    • Data Layer
  • Angular
    • Overview
    • Install
    • Track
    • API Reference
  • Google Tag Manager
    • Overview
    • Install
    • Data Layer
  • JavaScript (Web)
    • Overview
    • Install
    • Track
    • Data Layer
    • Universal Data Object (utag_data)
    • Universal Tag (utag.js)
    • Data Layer Object (b)
    • Single-Page Applications
    • Settings
    • Debugging
    • API Reference
      • Cookie Functions
      • GDPR Functions
      • Tracking Functions
      • Utility Functions
    • Release Notes
  • Server
  • C#
    • Overview
    • Install
    • Track
    • Data Layer
    • API Reference
    • Release Notes
  • HTTP API
    • Overview
    • Endpoint
    • Data Layer
  • Java
    • Overview
    • Install
    • Track
    • API Reference
    • Release Notes
  • Node
    • Overview
    • Install
    • Track
    • API Reference
  • Python
    • Overview
    • Install
    • Track
    • API Reference
  • Roku
    • Overview
    • Install
    • Track
    • API Reference
  • Ruby
    • Overview
    • Install
    • Track
    • API Reference
XAMARIN

Install

Learn to install Tealium for Xamarin 1.x.

The Tealium Xamarin integration provides a set of cross-platform interfaces and configuration classes that interface with the native Tealium iOS and Android SDKs.

Sample App

To help to familiarize yourself with our library, the tracking methods, and best practice implementation, download the Xamarin sample app.

Get the Code

Available DLLs

Several dynamic-link libraries (DLLs) are available for the Xamarin integration:

  • Tealium.Common.dll
    This DLL contains cross-platform code, interfaces, and common code to be used in all projects within your Xamarin application. Add this DLL as a reference in both shared project and platform specific projects.
  • Abstraction DLLs
    Abstraction DLLS are included to create a C# API wrapper for the native Tealium SDKs in platform specific projects. These libraries contain platform specific, concrete class implementations for the interfaces and abstract classes provided by the Tealium common library. Code all of your cross-platform logic against the common library.
    • Tealium.Droid.dll – for Android mobile platforms
    • Tealium.iOS.dll – for Apple mobile platforms

There are DLLs specific to each mobile platform which are referenced by the abstraction DLLs. The platform DLLs are binding libraries and therefore embedded in Tealium’s native SDKs. They provide auto-generated wrapper code that allows you to interact with our native SDKs directly and as a result they may be used standalone if desired.

  • Tealium.Platform.Droid.dll
  • Tealium.Platform.iOS.dll

Binding libraries may be used by themselves. The fact that they are automatically generated results in vastly different namespaces for each platform, which adds an extra complication to development efforts. It is advised to make use of the Common and platform-specific abstraction libraries instead.

Lifecycle Modules

An optional lifecycle module is available by referencing the relevant DLL for the platform. These are binding libraries for the native equivalent SDKs:

  • Tealium.Platform.Lifecycle.Droid.dll
  • Tealium.Platform.Lifecycle.iOS.dll

Android Example

The following example illustrates the Shared project and Android platform-specific project from a typical Xamarin based app:

Consent Manager Model

As shown in the example, the Shared Project references only the Tealium.Common.dll library, whereas the Android-specific project references all of the following:

  • Tealium.Common.dll
  • Tealium.Droid.dll
  • Tealium.Platform.Droid.dll
  • Tealium.Platform.Lifecycle.Droid.dll

Install

To install Tealium library for Xamarin, first verify that your projects reference the appropriate libraries. We recommend using the TealiumInstanceManager classes provided as they provide out-of-the-box, thread-safe Tealium instance management.

    using Tealium.Droid;
    //...
    
    ITealiumInstanceManager instanceManager = new TealiumInstanceManager(new TealiumInstanceFactoryDroid(<myAndroidApplication>));
    //Optional Lifecycle Module enablement - must reference Tealium.Platform.Lifecycle.Droid.dll
    TealiumLifecycleManager.SetLifecycleAutoTracking = TealiumDroid.Lifecycle.TealiumLifecycleControlDelegation.SetLifecycleAutoTracking;
    
    using Tealium.iOS;
    //...
    
    ITealiumInstanceManager instanceManager = new TealiumInstanceManager(new TealiumInstanceFactoryIOS());
    //Optional Lifecycle Module enablement - must reference Tealium.Platform.Lifecycle.iOS.dll
    TealiumLifecycleManager.SetLifecycleAutoTracking =TealiumIOS.Lifecycle.TealiumLifecycleControlDelegation.SetLifecycleAutoTracking;
    

    NuGet

    To install the Tealium library for Xamarin as a NuGet package, install it directly from Visual Studio using the built-in NuGet package manager. Learn more about the Tealium NuGet listing.

    Initialize

    Once the TealiumInstanceManager is created, begin creating Tealium instances as with the native SDKs. The TealiumInstanceManager is a multiton pattern that provides access to multiple named instances if you need to track data on more than one Tealium profile.

    To create a new instance, first create a TealiumConfig object with your account details:

    TealiumConfig tealConfig
         = new TealiumConfig(instance, account, profile, environment, lifecycleAutoTracking);
    
    
    Parameter Type Description Example
    instance String Tealium Instance ID "tealium_main"
    account String Tealium account name "companyXYZ"
    profile String Tealium profile name "main"
    environment String Tealium environment name ["dev", "qa", "prod"]
    lifecycleAutoTracking Boolean (Optional) Lifecycle auto-tracking (default: true) true`, `false

    Then use the TealiumInstanceManager to create a Tealium instance, which is used to track your events:

    ITealium tealium = instanceManager.CreateInstance(tealConfig);
    

    Advanced Configuration

    The TealiumConfig class has overloaded constructors for the option of specifying optional parameters to enable or disable the more advanced aspects of the Tealium Mobile SDKs. These parameters are optional as not all customers require these features.

    Remote Commands

    While the majority of the events within mobile are either sent to our data collection servers to be actioned through connectors, or processed in the tag management web view to trigger vendor tags, remote commands provide additional flexibility to trigger native code through the IRemoteCommand interface.

    The following sample code prints out the command ID (set to TealiumConsts.REMOTE_COMMAND_ID). This example also provides access to a full payload of data, as configured in the associated TagBridge Custom Command tag required to set this up:

    static List<IRemoteCommand> SetupRemoteCommands()
    {
        var command = new DelegateRemoteCommand(TealiumConsts.REMOTE_COMMAND_ID, "Test command " + TealiumConsts.REMOTE_COMMAND_ID) {
            HandleResponseDelegate = (DelegateRemoteCommand cmd,
                IRemoteCommandResponse resp) => {
                    System.Diagnostics.Debug.WriteLine($"Handling command {cmd.CommandId}...");
                }
            };
        return new List<IRemoteCommand>() { command };
    }
    

    Learn more about remote commands.

    Delegate Methods

    There are five delegated methods that allow you to inject code into the processing logic within the Tealium SDK:

    Delegated Method Description
    DelegateDispatchValidator() Provides two delegate methods [ShouldDropDispatchDelegate(), ShouldQueueDispatchDelegate()] where the boolean return value determines whether or not an existing dispatch is dropped or queued – Useful if you have steps within your app where you know that the user may be offline or you specifically want to write your own batching logic
    DispatchSentDelegateEventListener() Called whenever a dispatch has been sent
    DispatchQueuedDelegateEventListener() Called whenever a dispatch has been queued
    WebViewReadyDelegateEventListener() Called when the WebView is fully loaded and ready, if you are using the Tag Management module
    SettingsPublishedDelegateEventListener() Called when there has been an updated set of publish settings retrieved

    The following example illustrates the usage of the delegate method:

    static TealiumAdvancedConfig SetupAdvancedConfig() {
    
        DelegateDispatchValidator validator = new DelegateDispatchValidator() {
            ShouldDropDispatchDelegate = (ITealium arg1, IDispatch arg2) => {
                System.Diagnostics.Debug.WriteLine("Inside ShouldDropDispatchDelegate!");
                return false;
            },
            ShouldQueueDispatchDelegate = (ITealium arg1, IDispatch arg2, bool shouldQueue) => {
                System.Diagnostics.Debug.WriteLine("Inside ShouldQueueDispatchDelegate!");
                return shouldQueue;
            }
        };
        DispatchSentDelegateEventListener sendingListener = new DispatchSentDelegateEventListener() {
            DispatchSent = (tealium, dispatch) => {
                System.Diagnostics.Debug.WriteLine("Inside DispatchSent!");
                dispatch.PutString("KeyAddedBySendListener", "Value added by sending listener.");
            }
        };
        DispatchQueuedDelegateEventListener queuingListener = new DispatchQueuedDelegateEventListener() {
            DispatchQueued = (tealium, dispatch) => {
                System.Diagnostics.Debug.WriteLine("Inside DispatchQueued!");
                dispatch.PutString("KeyAddedByQueuedListener", "Value added by queuing listener.");
            }
        };
        WebViewReadyDelegateEventListener webViewListener = new WebViewReadyDelegateEventListener() {
            WebViewReady = (tealium, webView) =>  {
                System.Diagnostics.Debug.WriteLine("Inside WebViewReady!");
            }
        };
        SettingsPublishedDelegateEventListener settingsListener = new SettingsPublishedDelegateEventListener() {
            SettingsPublished = (tealium) => {
                System.Diagnostics.Debug.WriteLine("Inside SettingsPublished!");
            }
        };
        TealiumAdvancedConfig advConfig = new TealiumAdvancedConfig(validator,
            sendingListener, queuingListener, webViewListener, settingsListener);
    
        return advConfig;
    }
    

    Resources

    The following resources provide links to Xamarin’s extensive documentation for adding Tealium’s Android and iOS libraries:

    • Xamarin
    • Binding a Java Library
    • Xamarin - Binding an iOS Objective-C Library
    • Walkthrough: Binding an iOS Objective-C Library
    Next
    Track
    "Track"

     

    Was this article helpful?

    This page was last updated: December 15, 2021      

    Thank you for your feedback!

    Table of Contents

    • Sample App
    • Get the Code
    • Install
      • NuGet
    • Initialize
    • Advanced Configuration
      • Remote Commands
      • Delegate Methods
    • Resources
    • Platforms
    • Partners
    • Forums
    • Mobile
    • Getting Started
    • Remote Commands
    • Android (Java)
    • Android (Kotlin)
    • Cordova 1.x
    • Cordova 2.x
    • Flutter 1.x
    • Flutter 2.x
    • iOS (Objective-C)
    • iOS (Swift) 1.x
    • iOS (Swift) 2.x
    • NativeScript
    • React Native 1.x
    • React Native 2.x
    • Unity 1.x
    • Unity 2.x
    • Xamarin 1.x
    • Xamarin 2.x
    • Web
    • Getting Started
    • Adobe Launch
    • AMP
    • Angular
    • Google Tag Manager
    • JavaScript (Web)
    • Server
    • C#
    • HTTP API
    • Java
    • Node
    • Python
    • Roku
    • Ruby