Edit in GitHubLog an issue

Java

Import the library:

Copied to your clipboard
import com.adobe.marketing.mobile.*;

Swift

In Swift, the ACPCore library includes ACPIdentity:

Copied to your clipboard
import ACPCore

Objective-C

Copied to your clipboard
#import "ACPIdentity.h"

JavaScript

Copied to your clipboard
import {ACPIdentity} from '@adobe/react-native-acpcore';

Dart

Copied to your clipboard
import 'package:flutter_acpcore/flutter_acpidentity.dart';

Cordova

After creating your Cordova app and adding the Android and iOS platforms, the Identity extension for Cordova can be added with this command:

Copied to your clipboard
cordova plugin add https://github.com/adobe/cordova-acpcore.git

C#

After importing the ACPCore.unitypackage, the Identity extension for Unity can be added with following code in the MainScript

Copied to your clipboard
using com.adobe.marketing.mobile;

C#

After adding the iOS ACPCore NuGet package or the Android ACPIdentity NuGet package, the Identity extension can be added by this import statement

Copied to your clipboard
using Com.Adobe.Marketing.Mobile;

After calling the setApplication() method in the onCreate() method, register the extension. If the registration was not successful, an InvalidInitException is thrown.

Java

Copied to your clipboard
public class MobiletApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
try {
Identity.registerExtension();
} catch (Exception e) {
//Log the exception
}
}
}

Register the Identity extension in your app's didFinishLaunchingWithOptions function:

Swift

Copied to your clipboard
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
ACPIdentity.registerExtension();
// Override point for customization after application launch.
return true;
}

Objective-C

Copied to your clipboard
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[ACPIdentity registerExtension];
// Override point for customization after application launch.
return YES;
}

When using React Native, registering Identity with Mobile Core should be done in native code, which is shown under the Android and iOS tabs.

When using Flutter, registering Identity with Mobile Core should be done in native code, which is shown under the Android and iOS tabs.

When using React Native, registering Identity with Mobile Core should be done in native code, which is shown under the Android and iOS tabs.

Register the Identity extension in your app's Start() function:

C#

Copied to your clipboard
void Start() {
ACPIdentity.RegisterExtension();
}

C#

iOS

Register the Identity extension in your app's FinishedLaunching() function:

Copied to your clipboard
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
ACPIdentity.RegisterExtension();
// start core
ACPCore.Start(startCallback);
return base.FinishedLaunching(app, options);
}
private void startCallback()
{
// set launch config
ACPCore.ConfigureWithAppID("yourAppId");
}

Android

Register the Identity extension in your app's OnCreate() function:

Copied to your clipboard
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
ACPIdentity.RegisterExtension();
// start core
ACPCore.Start(new CoreStartCompletionCallback());
}
class CoreStartCompletionCallback : Java.Lang.Object, IAdobeCallback
{
public void Call(Java.Lang.Object callback)
{
// set launch config
ACPCore.ConfigureWithAppID("yourAppId");
}
}

Java

To append visitor information to the URL that is being used to open the web view, call appendVisitorInfoForUrl:

Copied to your clipboard
Identity.appendVisitorInfoForURL("https://example.com", new AdobeCallback<String>() {
@Override
public void call(String urlWithAdobeVisitorInfo) {
//handle the new URL here
//For example, open the URL on the device browser
//
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(urlWithAdobeVisitorInfo));
startActivity(i);
}
});

Alternately, starting in SDK version 1.4.0 (Identity version 1.1.0), you can call getUrlVariables and build your own URL:

Copied to your clipboard
Identity.getUrlVariables(new AdobeCallback<String>() {
@Override
public void call(String stringWithAdobeVisitorInfo) {
//handle the URL query parameter string here
//For example, open the URL on the device browser
//
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://example.com?" + urlWithAdobeVisitorInfo));
startActivity(i);
}
});

Objective-C

To append visitor information to the URL that is being used to open the web view, call appendToUrl:

Copied to your clipboard
NSURL* url = [[NSURL alloc] initWithString:@"www.example.com"];
[ACPIdentity appendToUrl:url withCallback:^(NSURL * _Nullable urlWithVisitorData) {
// handle the appended url here
}];

Alternately, starting with SDK version 2.3.0 (ACPIdentity version 2.1.0), you can call getUrlVariables and build your own URL:

Copied to your clipboard
[ACPIdentity getUrlVariables:^(NSString * _Nullable urlVariables) {
// handle the URL query parameter string here
NSString* urlString = @"https://example.com";
NSString* urlStringWithVisitorData = [NSString stringWithFormat:@"%@?%@", urlString, urlVariables];
NSURL* urlWithVisitorData = [NSURL URLWithString:urlStringWithVisitorData];
[[UIApplication sharedApplication] openURL:urlWithVisitorData options:@{} completionHandler:^(BOOL success) {
// handle openURL success
}];
}];

JavaScript

To append visitor information to the URL that is being used to open the web view, call appendVisitorInfoForUrl:

Copied to your clipboard
ACPIdentity.appendVisitorInfoForURL("www.example.com").then(urlWithVistorData => console.log("Url with Visitor Data = " + urlWithVisitorData));

Alternately, starting with SDK version 1.0.5, you can call getUrlVariables and build your own URL:

Copied to your clipboard
ACPIdentity.getUrlVariables().then(urlVariables => console.log("query params = " + urlVariables));

Dart

To append visitor information to the URL that is being used to open the web view, call appendVisitorInfoForUrl:

Copied to your clipboard
String result = "";
try {
result = await FlutterACPIdentity.appendToUrl("www.example.com");
} on PlatformException {
log("Failed to append URL");
}

Alternately, starting with SDK version 1.0.0-beta.1, you can call getUrlVariables and build your own URL:

Copied to your clipboard
String result = "";
try {
result = await FlutterACPIdentity.urlVariables;
} on PlatformException {
log("Failed to get url variables");
}

Cordova

To append visitor information to the URL that is being used to open the web view, call appendVisitorInfoForUrl:

Copied to your clipboard
ACPIdentity.appendVisitorInfoForUrl("https://example.com", function(handleCallback) {
console.log("AdobeExperenceSDK: Url with Visitor Data = " + handleCallback);
}, function(handleError) {
console.log("AdobeExperenceSDK: Failed to append URL : " + handleError);
});

Alternately, you can call getUrlVariables and build your own URL:

Copied to your clipboard
ACPIdentity.getUrlVariables(function (handleCallback) {
console.log("AdobeExperienceSDK: Url variables: " + handleCallback);
}, function (handleError) {
console.log("AdobeExperenceSDK: Failed to retrieve url variables : " + handleError);
});

C#

To append visitor information to the URL that is being used to open the web view, call AppendToUrl:

Copied to your clipboard
[MonoPInvokeCallback(typeof(AdobeIdentityAppendToUrlCallback))]
public static void HandleAdobeIdentityAppendToUrlCallback(string url)
{
print("Url is : " + url);
}
ACPIdentity.AppendToUrl("https://www.adobe.com", HandleAdobeIdentityAppendToUrlCallback);

Alternately, you can call GetUrlVariables and build your own URL:

Copied to your clipboard
[MonoPInvokeCallback(typeof(AdobeGetUrlVariables))]
public static void HandleAdobeGetUrlVariables(string urlVariables)
{
print("Url variables are : " + urlVariables);
}
ACPIdentity.GetUrlVariables(HandleAdobeGetUrlVariables);

C#

To append visitor information to the URL that is being used to open the web view, call AppendToUrl:

iOS

Copied to your clipboard
ACPIdentity.AppendToUrl(url, callback => {
Console.WriteLine("Appended url: " + callback);
});

To append visitor information to the URL that is being used to open the web view, call AppendVisitorInfoForUrl:

Android

Copied to your clipboard
ACPIdentity.AppendVisitorInfoForURL("https://example.com", new StringCallback());
class StringCallback : Java.Lang.Object, IAdobeCallback
{
public void Call(Java.Lang.Object stringContent)
{
if (stringContent != null)
{
Console.WriteLine("Appended url: " + stringContent);
}
else
{
Console.WriteLine("null content in string callback");
}
}
}

Alternately, you can call GetUrlVariables and build your own URL:

iOS

Copied to your clipboard
ACPIdentity.GetUrlVariables(callback => {
Console.WriteLine("Url variables: " + callback);
});

Android

Copied to your clipboard
ACPIdentity.GetUrlVariables(new StringCallback());
class StringCallback : Java.Lang.Object, IAdobeCallback
{
public void Call(Java.Lang.Object stringContent)
{
if (stringContent != null)
{
Console.WriteLine("Url variables: " + stringContent);
}
else
{
Console.WriteLine("null content in string callback");
}
}
}
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.