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.
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.
Plugins for a Unity project use the following folder structure:
{Project}/Assets/Plugins/{Platform}
- Download ACPCore-1.0.1-Unity.zip
- Unzip
ACPCore-1.0.1-Unity.zip
- Import
ACPCore.unitypackage
via Assets-Import Package
No additional steps are required for Android 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.
- Go to File -> Project Settings -> Build System and select
New Build System
. - Download
ACPCore.xcframework
,ACPIdentity.xcframework
,ACPLifecycle.xcframework
andACPSignal.xcframework
. - Select the UnityFramework target -> Go to Build Phases tab -> Add the XCFrameworks downloaded in Step 2 to
Link Binary with Libraries
. - Select the Unity-iPhone target -> Go to Build Phases tab -> Add the XCFrameworks downloaded in Steps 2 to
Link Binary with Libraries
andEmbed Frameworks
. Alternatively, selectUnity-iPhone
target -> Go toGeneral
tab -> Add the XCFrameworks downloaded in Steps 2 toFrameworks, Libraries, and Embedded Content
-> SelectEmbed and sign
option.
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);
}
}
ACPCore.ExtensionVersion();
var dict = new Dictionary<string, object>();
dict.Add("newConfigKey", "newConfigValue");
ACPCore.UpdateConfiguration(dict);
ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.ERROR);
ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.WARNING);
ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.DEBUG);
ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.VERBOSE);
[MonoPInvokeCallback(typeof(AdobePrivacyStatusCallback))]
public static void HandleAdobePrivacyStatusCallback(int status)
{
print("Privacy status is : " + ((ACPCore.ACPMobilePrivacyStatus)status).ToString());
}
ACPCore.GetPrivacyStatus(HandleAdobePrivacyStatusCallback);
ACPCore.SetPrivacyStatus(ACPCore.ACPMobilePrivacyStatus.OPT_IN);
ACPCore.SetPrivacyStatus(ACPCore.ACPMobilePrivacyStatus.OPT_OUT);
ACPCore.SetPrivacyStatus(ACPCore.ACPMobilePrivacyStatus.UNKNOWN);
[MonoPInvokeCallback(typeof(AdobeIdentitiesCallback))]
public static void HandleGetIdentitiesAdobeCallback(string ids)
{
if (ids is string)
{
print("Ids are : " + ids);
}
}
ACPCore.GetSdkIdentities(HandleGetIdentitiesAdobeCallback);
[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);
[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);
[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);
ACPCore.DownloadRules();
ACPCore.SetAdvertisingIdentifier("AdId");
var contextData = new Dictionary<string, string>();
contextData.Add("key", "value");
ACPCore.TrackAction("action", contextData);
var dict = new Dictionary<string, string>();
dict.Add("key", "value");
ACPCore.TrackState("state", dict);
string identityVersion = ACPIdentity.ExtensionVersion();
ACPIdentity.SyncIdentifier("idType1", "idValue1", ACPIdentity.ACPAuthenticationState.AUTHENTICATED);
Dictionary<string, string> ids = new Dictionary<string, string>();
ids.Add("idsType1", "idValue1");
ids.Add("idsType2", "idValue2");
ids.Add("idsType3", "idValue3");
ACPIdentity.SyncIdentifiers(ids);
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);
[MonoPInvokeCallback(typeof(AdobeIdentityAppendToUrlCallback))]
public static void HandleAdobeIdentityAppendToUrlCallback(string url)
{
print("Url is : " + url);
}
ACPIdentity.AppendToUrl("https://www.adobe.com", HandleAdobeIdentityAppendToUrlCallback);
[MonoPInvokeCallback(typeof(AdobeGetUrlVariables))]
public static void HandleAdobeGetUrlVariables(string urlVariables)
{
print("Url variables are : " + urlVariables);
}
ACPIdentity.GetUrlVariables(HandleAdobeGetUrlVariables);
[MonoPInvokeCallback(typeof(AdobeGetIdentifiersCallback))]
public static void HandleAdobeGetIdentifiersCallback(string visitorIds)
{
print("Ids is : " + visitorIds);
_result = "Ids is : " + visitorIds;
}
ACPIdentity.GetIdentifiers(HandleAdobeGetIdentifiersCallback);
[MonoPInvokeCallback(typeof(AdobeGetExperienceCloudIdCallback))]
public static void HandleAdobeGetExperienceCloudIdCallback(string cloudId)
{
print("ECID is : " + cloudId);
}
ACPIdentity.GetExperienceCloudId(HandleAdobeGetExperienceCloudIdCallback);
private void OnApplicationPause(bool pauseStatus)
{
if (pauseStatus)
{
ACPCore.LifecyclePause();
}
else
{
var cdata = new Dictionary<string, string>();
cdata.Add("launch.data", "added");
ACPCore.LifecycleStart(cdata);
}
}
string lifecycleVersion = ACPLifecycle.ExtensionVersion();
string signalVersion = ACPSignal.ExtensionVersion();
- Open the demo app in unity.
- Open the test runner from
Window -> General -> TestRunner
. - Click on the
PlayMode
tab. - Connect an Android device. As we run the tests on a device in play mode.
- Click
Run all in player (Android)
to run the tests.
Sample App is located in the unity-acpcore/ACPCore/Assets/Demo. To build demo app for specific platform follow the below instructions.
- Make sure you have an Android device connected.
- From the menu of the
Unity
app, select File > Build Settings... - Select
Android
from the Platform window - 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) - Press the Build And Run button
- 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)
- Name build whatever you want and press Save
Unity
will build anapk
file and automatically deploy it to the connected device
- From the menu of the
Unity
app, select File > Build Settings... - Select
iOS
from the Platform window - 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) - Press the Build And Run button
- 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)
- Name build whatever you want and press Save
Unity
will create and open anXcode
project- Add XCFrameworks to the Xcode project.
- From the Xcode project run the app on a simulator.
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 |
Looking to contribute to this project? Please review our Contributing guidelines prior to opening a pull request.
We look forward to working with you!
This project is licensed under the Apache V2 License. See LICENSE for more information.