Skip to content

Adobe Experience Platform - Core package for Unity apps.

License

Notifications You must be signed in to change notification settings

isabella232/unity-acpcore

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Adobe Experience Platform - Core plugin for unity apps

Prerequisites

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.

FOLDER STRUCTURE

Plugins for a Unity project use the following folder structure:

{Project}/Assets/Plugins/{Platform}

Installation

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

Usage

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);
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);
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();
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. From the Xcode project run the app on a simulator.
  9. If you get an error Symbol not found: _OBJC_CLASS_$_WKWebView. Select the Unity-iPhone target -> Go to Build Phases tab -> Add Webkit.Framework to Link Binary with Libraries.

Additional Cordova Plugins

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

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.

About

Adobe Experience Platform - Core package for Unity apps.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 49.0%
  • Objective-C 31.5%
  • Objective-C++ 13.8%
  • C 4.4%
  • Makefile 1.3%