The Unity Hub
application is required for development and testing. Inside of Unity Hub
, you will be required to download the current version of the Unity
app.
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-0.0.1-Unity.zip
- Unzip
ACPCore-0.0.1-Unity.zip
- Import
ACPCore.unitypackage
via Assets-Import Package
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- From the Xcode project run the app on a simulator.
- If you get an error
Symbol not found: _OBJC_CLASS_$_WKWebView
. Select the Unity-iPhone target -> Go to Build Phases tab -> AddWebkit.Framework
toLink Binary with Libraries
.
Below is a list of additional Unity plugins from the AEP SDK suite:
Extension | GitHub | Unity Package |
---|---|---|
Adobe Analytics | https://github.com/adobe/unity-acpanalytics | ACPAnalytics |
Project Griffon (Beta) | https://github.com/adobe/unity-acpgriffon | ACPGriffon |
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.