Skip to content

adobe/unity-acpcore

master
Switch branches/tags
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
bin
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Adobe Experience Platform - Core plugin for unity apps

End of support

Effective March 30, 2022, support for Adobe Experience Platform Mobile SDKs on Unity is no longer active. While you may continue using our libraries, Adobe no longer plans to update, modify, or provide support for these libraries. Please contact your Adobe CSM for detail.

Prerequisites

The Unity Hub application is required for development and testing. Inside of Unity Hub, you will be required to download the Unity app. The ACPCore Unity package is built using Unity version 2019.4.

Download the Unity Hub. The free version works for development and testing, but a Unity Pro license is required for distribution. See Distribution below for details.

FOLDER STRUCTURE

Plugins for a Unity project use the following folder structure:

{Project}/Assets/Plugins/{Platform}

Installation

Installing the ACPCore Unity Package

  • Download ACPCore-1.0.1-Unity.zip
  • Unzip ACPCore-1.0.1-Unity.zip
  • Import ACPCore.unitypackage via Assets-Import Package

Android installation

No additional steps are required for Android installation.

iOS installation

ACPCore 1.0.1 and above is shipped with XCFrameworks. Follow these steps to add them to the Xcode project generated when building and running for iOS platform in Unity.

  1. Go to File -> Project Settings -> Build System and select New Build System.
  2. Download ACPCore.xcframework, ACPIdentity.xcframework, ACPLifecycle.xcframework and ACPSignal.xcframework.
  3. Select the UnityFramework target -> Go to Build Phases tab -> Add the XCFrameworks downloaded in Step 2 to Link Binary with Libraries.
  4. Select the Unity-iPhone target -> Go to Build Phases tab -> Add the XCFrameworks downloaded in Steps 2 to Link Binary with Libraries and Embed Frameworks. Alternatively, select Unity-iPhone target -> Go to General tab -> Add the XCFrameworks downloaded in Steps 2 to Frameworks, Libraries, and Embedded Content -> Select Embed and sign option.

Usage

Core

Initialization

Initialize by registering the extensions and calling the start function fo core
using com.adobe.marketing.mobile;
using AOT;

public class MainScript : MonoBehaviour
{
    [MonoPInvokeCallback(typeof(AdobeStartCallback))]
    public static void HandleStartAdobeCallback()
    {   
        ACPCore.ConfigureWithAppID("1423ae38-8385-8963-8693-28375403491d"); 
    }

    // Start is called before the first frame update
    void Start()
    {   
        if (Application.platform == RuntimePlatform.Android) {
            ACPCore.SetApplication();
        }
        
        ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.VERBOSE);
        ACPCore.SetWrapperType();
        ACPIdentity.registerExtension();
        ACPLifecycle.registerExtension();
        ACPSignal.registerExtension();
        ACPCore.Start(HandleStartAdobeCallback);
    }
}

Core methods

Getting Core version:
ACPCore.ExtensionVersion();
Updating the SDK configuration:
var dict = new Dictionary<string, object>();
dict.Add("newConfigKey", "newConfigValue");
ACPCore.UpdateConfiguration(dict);
Controlling the log level of the SDK:
ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.ERROR);
ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.WARNING);
ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.DEBUG);
ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.VERBOSE);
Getting the current privacy status:
[MonoPInvokeCallback(typeof(AdobePrivacyStatusCallback))]
public static void HandleAdobePrivacyStatusCallback(int status)
{
    print("Privacy status is : " + ((ACPCore.ACPMobilePrivacyStatus)status).ToString());
}

ACPCore.GetPrivacyStatus(HandleAdobePrivacyStatusCallback);
Setting the privacy status:
ACPCore.SetPrivacyStatus(ACPCore.ACPMobilePrivacyStatus.OPT_IN);
ACPCore.SetPrivacyStatus(ACPCore.ACPMobilePrivacyStatus.OPT_OUT);
ACPCore.SetPrivacyStatus(ACPCore.ACPMobilePrivacyStatus.UNKNOWN);
Getting the SDK identities:
[MonoPInvokeCallback(typeof(AdobeIdentitiesCallback))]
public static void HandleGetIdentitiesAdobeCallback(string ids)
{
    if (ids is string)
    {
        print("Ids are : " + ids);
    }
}

ACPCore.GetSdkIdentities(HandleGetIdentitiesAdobeCallback);
Dispatching an Event Hub event:
[MonoPInvokeCallback(typeof(AdobeExtensionErrorCallback))]
public static void HandleAdobeExtensionErrorCallback(string errorName, int errorCode)
{
    print("Error is : " + errorName);
}

var dict = new Dictionary<string, object>();
dict.Add("key", "value");
ACPCore.DispatchEvent(new ACPExtensionEvent("eventName", "eventType", "eventSource", dict), HandleAdobeExtensionErrorCallback);
Dispatching an Event Hub event with callback:
[MonoPInvokeCallback(typeof(AdobeExtensionErrorCallback))]
public static void HandleAdobeExtensionErrorCallback(string errorName, int errorCode)
{
    print("Error is : " + errorName);
}

[MonoPInvokeCallback(typeof(AdobeEventCallback))]
public static void HandleAdobeEventCallback(string eventName, string eventType, string eventSource, string jsonEventData)
{
    print("Event is : " + eventName);
}

var dict = new Dictionary<string, object>();
dict.Add("key", "value");
ACPCore.DispatchEventWithResponseCallback(new ACPExtensionEvent("eventname", "eventType", "eventSource", dict), HandleAdobeEventCallback, HandleAdobeExtensionErrorCallback);
Dispatching an Event Hub response event:
[MonoPInvokeCallback(typeof(AdobeExtensionErrorCallback))]
public static void HandleAdobeExtensionErrorCallback(string errorName, int errorCode)
{
    print("Error is : " + errorName);
}

var dictResponse = new Dictionary<string, object>();
dictResponse.Add("eventDataKeyRes", "eventDataValueRes");
var dictRequest = new Dictionary<string, object>();
dictRequest.Add("eventDataKeyReq", "eventDataValueReq");
ACPCore.DispatchResponseEvent(new ACPExtensionEvent("responseEventName", "eventType", "eventSource", dictResponse), new ACPExtensionEvent("requestEventName", "eventType", "eventSource", dictRequest), HandleAdobeExtensionErrorCallback);
Downloading the Rules
ACPCore.DownloadRules();
Setting the advertising identifier:
ACPCore.SetAdvertisingIdentifier("AdId");
Calling track action
var contextData = new Dictionary<string, string>();
contextData.Add("key", "value");
ACPCore.TrackAction("action", contextData);
Calling track state
var dict = new Dictionary<string, string>();
dict.Add("key", "value");
ACPCore.TrackState("state", dict);

Identity

Getting Identity version:
string identityVersion = ACPIdentity.ExtensionVersion();
Sync Identifier:
ACPIdentity.SyncIdentifier("idType1", "idValue1", ACPIdentity.ACPAuthenticationState.AUTHENTICATED);
Sync Identifiers:
Dictionary<string, string> ids = new Dictionary<string, string>();
ids.Add("idsType1", "idValue1");
ids.Add("idsType2", "idValue2");
ids.Add("idsType3", "idValue3");
ACPIdentity.SyncIdentifiers(ids);
Sync Identifiers with Authentication State:
Dictionary<string, string> ids = new Dictionary<string, string>();
ids.Add("idsType1", "idValue1");
ids.Add("idsType2", "idValue2");
ids.Add("idsType3", "idValue3");
ACPIdentity.SyncIdentifiers(ids, ACPIdentity.ACPAuthenticationState.AUTHENTICATED);
ACPIdentity.SyncIdentifiers(ids, ACPIdentity.ACPAuthenticationState.LOGGED_OUT);
ACPIdentity.SyncIdentifiers(ids, ACPIdentity.ACPAuthenticationState.UNKNOWN);
Append visitor data to a URL:
[MonoPInvokeCallback(typeof(AdobeIdentityAppendToUrlCallback))]
public static void HandleAdobeIdentityAppendToUrlCallback(string url)
{
    print("Url is : " + url);
}
ACPIdentity.AppendToUrl("https://www.adobe.com", HandleAdobeIdentityAppendToUrlCallback);
Get visitor data as URL query parameter string:
[MonoPInvokeCallback(typeof(AdobeGetUrlVariables))]
public static void HandleAdobeGetUrlVariables(string urlVariables)
{
    print("Url variables are : " + urlVariables);
}
ACPIdentity.GetUrlVariables(HandleAdobeGetUrlVariables);
Get Identifiers:
[MonoPInvokeCallback(typeof(AdobeGetIdentifiersCallback))]
public static void HandleAdobeGetIdentifiersCallback(string visitorIds)
{
    print("Ids is : " + visitorIds);
    _result = "Ids is : " + visitorIds;
}
ACPIdentity.GetIdentifiers(HandleAdobeGetIdentifiersCallback);
Get Experience Cloud IDs:
[MonoPInvokeCallback(typeof(AdobeGetExperienceCloudIdCallback))]
public static void HandleAdobeGetExperienceCloudIdCallback(string cloudId)
{
    print("ECID is : " + cloudId);
}
ACPIdentity.GetExperienceCloudId(HandleAdobeGetExperienceCloudIdCallback);

Lifecycle

Starting and pausing a lifecycle event
private void OnApplicationPause(bool pauseStatus)
{
  if (pauseStatus)
  {
    ACPCore.LifecyclePause();
  }
  else
  {
    var cdata = new Dictionary<string, string>();
    cdata.Add("launch.data", "added");
    ACPCore.LifecycleStart(cdata);
  }
}
Getting Lifecycle version:
string lifecycleVersion = ACPLifecycle.ExtensionVersion();

Signal

Getting Signal version:
string signalVersion = ACPSignal.ExtensionVersion();

Running Tests

  1. Open the demo app in unity.
  2. Open the test runner from Window -> General -> TestRunner.
  3. Click on the PlayMode tab.
  4. Connect an Android device. As we run the tests on a device in play mode.
  5. Click Run all in player (Android) to run the tests.

Sample App

Sample App is located in the unity-acpcore/ACPCore/Assets/Demo. To build demo app for specific platform follow the below instructions.

Android
  1. Make sure you have an Android device connected.
  2. From the menu of the Unity app, select File > Build Settings...
  3. Select Android from the Platform window
  4. If Android is not the active platform, hit the button that says Switch Platform (it will only be available if you actually need to switch active platforms)
  5. Press the Build And Run button
  6. You will be asked to provide a location to save the build. Make a new directory at unity-acpcore/ACPCore/Builds (this folder is in the .gitignore file)
  7. Name build whatever you want and press Save
  8. Unity will build an apk file and automatically deploy it to the connected device
iOS
  1. From the menu of the Unity app, select File > Build Settings...
  2. Select iOS from the Platform window
  3. If iOS is not the active platform, hit the button that says Switch Platform (it will only be available if you actually need to switch active platforms)
  4. Press the Build And Run button
  5. You will be asked to provide a location to save the build. Make a new directory at unity-acpcore/ACPCore/Builds (this folder is in the .gitignore file)
  6. Name build whatever you want and press Save
  7. Unity will create and open an Xcode project
  8. Add XCFrameworks to the Xcode project.
  9. From the Xcode project run the app on a simulator.

Additional Unity Plugins

Below is a list of additional Unity plugins from the ACP SDK suite:

Extension GitHub Unity Package
ACPAnalytics https://github.com/adobe/unity-acpanalytics ACPAnalytics
AEPAssurance https://github.com/adobe/unity-acpgriffon AEPAssurance
ACPUserProfile https://github.com/adobe/unity_acpuserprofile ACPUserProfile

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.