adobe / xamarin-acpanalytics

Adobe Experience Platform - Analytics plugin for Xamarin apps.
Apache License 2.0
2 stars 8 forks source link

Adobe Experience Platform - Analytics plugin for Xamarin apps

Notice of deprecation

Since April 25, 2023, Apple has required apps submitted to the App Store to be built with Xcode 14.1 or later. The Experience Platform Mobile SDKs and extensions outlined below were built with prior versions of Xcode and are no longer compatible with iOS and iPadOS given Apple’s current App Store requirements. Consequently, on August 31, 2023, Adobe will be deprecating support for the following Experience Platform Mobile SDKs and wrapper extensions:

After August 31, 2023, applications already submitted to the App Store that contain these SDKs and wrapper extensions will continue to operate, however, Adobe will not be providing security updates or bug fixes, and these SDKs and wrapper extensions will be provided as-is exclusive of any warranty, due to the App Store policy outlined above.

We encourage all customers to migrate to the latest Adobe Experience Platform versions of the Mobile SDK to ensure continued compatibility and support. Documentation for the latest versions of the Adobe Experience Platform Mobile SDKs can be found here. The iOS migration guide can be found here.


CI NuGet NuGet NuGet GitHub

Prerequisites

Xamarin development requires the installation of Microsoft Visual Studio. Information regarding installation for Xamarin development is available for Mac or Windows.

An Apple developer account and the latest version of Xcode (available from the App Store) are required if you are building an iOS or tvOS app.

Installation

Package Manager Installation

The ACPAnalytics Xamarin NuGet package for Android or iOS or tvOS can be added to your project by right clicking the "Packages" folder within the project you are working on then selecting "Manage NuGet Packages". In the window that opens, ensure that your selected source is nuget.org and search for "Adobe.ACP". After selecting the Xamarin AEP SDK packages that are required, click on the "Add Packages" button. After exiting the "Add Packages" menu, right click the main solution or the "Packages" folder and select "Restore" to ensure the added packages are downloaded.

Manual installation

Local ACPAnalytics NuGet packages can be created via the included Makefile. If building for the first time, run:

make setup

followed by:

make release

The created NuGet packages can be found in the bin directory. This directory can be added as a local nuget source and packages within the directory can be added to a Xamarin project following the steps in the "Package Manager Installation" above.

Usage

The ACPAnalytics binding can be opened by loading the ACPAnalyticsBinding.sln with Visual Studio. The following targets are available in the solution:

Analytics

Getting Analytics version:

iOS and Android

Console.WriteLine(ACPAnalytics.ExtensionVersion());
Registering the extension with ACPCore:
iOS and Android
using Com.Adobe.Marketing.Mobile;

ACPAnalytics.RegisterExtension();
ACPCore.Start(null);
Get the tracking identifier:

iOS

var callback = new Action<NSString>(handleCallback);
ACPAnalytics.GetTrackingIdentifier(callback);

private void handleCallback(NSString content)
{
  Console.WriteLine("String callback: " + content);
}

Android

ACPAnalytics.GetTrackingIdentifier(new StringCallback());

class StringCallback : Java.Lang.Object, IAdobeCallback
{
  public void Call(Java.Lang.Object stringContent)
  {
    if (stringContent != null)
    {
      Console.WriteLine("String callback content: " + stringContent);
    }
    else
    {
      Console.WriteLine("null content in string callback");
    }
  }
}
Send queued hits:

iOS and Android

ACPAnalytics.SendQueuedHits();
Get the queue size:

iOS

var callback = new Action<nuint>(handleCallback);
ACPAnalytics.GetQueueSize(callback);

private void handleCallback(nuint value)
{
  Console.WriteLine("Queue size: " + value);
}

Android

ACPAnalytics.GetQueueSize(new StringCallback());

class StringCallback : Java.Lang.Object, IAdobeCallback
{
  public void Call(Java.Lang.Object stringContent)
  {
    if (stringContent != null)
    {
      Console.WriteLine("String callback content: " + stringContent);
    }
    else
    {
      Console.WriteLine("null content in string callback");
    }
  }
}
Clear queued hits:

iOS and Android

ACPAnalytics.ClearQueue(); 
Set the custom visitor identifier:

iOS and Android

ACPAnalytics.SetVisitorIdentifier("testVisitorIdentifier");
Get the custom visitor identifier:

iOS

var callback = new Action<NSString>(handleCallback);
ACPAnalytics.GetVisitorIdentifier(callback);

private void handleCallback(NSString content)
{
  Console.WriteLine("String callback: " + content);
}

Android

ACPAnalytics.GetVisitorIdentifier(new StringCallback());

class StringCallback : Java.Lang.Object, IAdobeCallback
{
  public void Call(Java.Lang.Object stringContent)
  {
    if (stringContent != null)
    {
      Console.WriteLine("String callback content: " + stringContent);
    }
    else
    {
      Console.WriteLine("null content in string callback");
    }
  }
}
Running Tests

iOS and Android unit tests are included within the ACPAnalytics binding solution. They must be built from within Visual Studio then manually triggered from the unit test app that is deployed to an iOS or Android device.

Sample App

A Xamarin Forms sample app is provided in the Xamarin ACPAnalytics solution file.

Contributing

Looking to contribute to this project? Please review our Contributing guidelines prior to opening a pull request.

We look forward to working with you!

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.