Campaign Classic API reference

extensionVersion

The extensionVersion API returns the version of the Campaign Classic extension that is registered with the Mobile Core extension.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)

Java

Syntax
1
public static String extensionVersion();
Copied!
Example
1
String campaignClassicExtensionVersion = CampaignClassic.extensionVersion();
Copied!
Adobe Campaign Classic has not yet been released as an AEP 3.x Swift extension. Please reach out to your Adobe customer account manager if you have any questions or would like to express interest in the AEP 3.x Campaign Classic extension.

Swift

Syntax
1
func extensionVersion() -> String
Copied!
Example
1
let campaignClassicExtensionVersion = ACPCampaignClassic.extensionVersion()
Copied!

Objective-C

Syntax
1
+(NSString) extensionVersion;
Copied!
Example
1
NSString *campaignClassicExtensionVersion = [ACPCampaignClassic extensionVersion];
Copied!

registerDevice

The registerDevice API lets you register a user device with Campaign Classic.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)
To prepare your app to handle push notifications, see the tutorial on setting up a Firebase Cloud Messaging client app on Android. After you receive the Firebase Cloud Messaging (FCM) SDK registration token, send this token and the device information to Campaign Classic by using the registerDevice API.
The registerDevice API registers a device with your Campaign Classic registration server. It takes the FCM registration token as a parameter with a user key that identifies a user, such as an email address or a login name. You can also provide a map of the custom key-value pairs that you want to associate with the registration. A boolean value is returned in the callback, which signals whether the registration was successful.

Java

Syntax
1
public static void registerDevice(final String token, final String userKey, final Map<String, Object> additionalParams, final AdobeCallback<Boolean> callback)
Copied!
Example
1
@Override
2
public void onNewToken(String token) {
3
Log.d("TestApp", "Refreshed token: " + token);
4
5
// If you want to send messages to this application instance or
6
// manage this app's subscriptions on the server side, send the
7
// Instance ID token to your app server.
8
if (token != null) {
9
Log.d("TestApp", "FCM SDK registration token received : " + token);
10
// Create a map of additional parameters
11
Map<String, Object> additionalParams = new HashMap<String, Object>();
12
additionalParams.put("name", "John");
13
additionalParams.put("serial", 12345);
14
additionalParams.put("premium", true);
15
// Send the registration info
16
CampaignClassic.registerDevice(token, "[email protected]", additionalParams,new AdobeCallback<Boolean>() {
17
@Override
18
public void call(final Boolean status) {
19
Log.d("TestApp", "Registration Status: " + status);
20
}
21
});
22
}
23
}
Copied!
Adobe Campaign Classic has not yet been released as an AEP 3.x Swift extension. Please reach out to your Adobe customer account manager if you have any questions or would like to express interest in the AEP 3.x Campaign Classic extension.
To get your app ready to handle push notifications, see the tutorial on configuring remote notification support. After you receive the Apple Push Notification service (APNs) token, send this token and the device information to Campaign Classic using the registerDevice API.
The registerDevice API registers a device with your Campaign Classic registration server. It takes the APNS token as a parameter with a user key that identifies a user, such as an email address or a login name. You can also provide a map of the custom key-value pairs that you want to associate with the registration. A boolean value is returned in the callback, which signals whether the registration was successful.

Swift

Syntax
1
func registerDevice(_ token: Data, userKey: String?, additionalParams: [String: Any]?, callback: ((Bool) -> Void)?)
Copied!
Example
1
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
2
let params: [String: Any] = [
3
"name": "John",
4
"serial": 12345,
5
"premium": true
6
]
7
ACPCampaignClassic.registerDevice(deviceToken, userKey: "[email protected]", additionalParams: params) {
8
result in
9
print("Registration status: \(result)")
10
}
11
}
Copied!

Objective-C

Syntax
1
+ (void) registerDevice: (nonnull NSData*) token userKey: (nullable NSString*) userKey additionalParams: (nullable NSDictionary*) additionalParams callback: (nullable void (^) (BOOL success)) callback;
Copied!
Example
1
- (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
2
// Set the deviceToken that the APNS has assigned to the device
3
NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjectsAndKeys: @"John", @"name", nil];
4
[params setObject: [NSNumber numberWithInt:12345] forKey: @"serial"];
5
[params setObject: [NSNumber numberWithBool:YES] forKey: @"premium"];
6
7
[ACPCampaignClassic registerDevice:deviceToken userKey:@"[email protected]" additionalParams:params callback:^(BOOL success) {
8
NSLog(@"Registration Status: %d", success);
9
}
Copied!

trackNotificationClick

The trackNotificationClick API sends the clicked push notification's tracking information to the configured Adobe Campaign Classic server. This API can be used to send tracking information when the notification is clicked, which may result in the application being opened.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)

Java

If trackInfo is null, or does not contain the necessary tracking identifiers, messageId (_mId) and deliveryId (_dId), a track request is not sent.
Syntax
1
public static void trackNotificationClick(final Map<String, String> trackInfo)
Copied!
Example
1
@Override
2
public void onResume() {
3
super.onResume();
4
// Perform any other app related tasks
5
// The messageId (_mId) and deliveryId (_dId) can be passed in the intent extras.
6
// This is assuming you extract the messageId and deliveryId from the
7
// received push message and are including it in the intent (intent.putExtra())
8
// of the displayed notification.
9
10
Bundle extras = getIntent().getExtras();
11
if (extras != null) {
12
String deliveryId = extras.getString("_dId");
13
String messageId = extras.getString("_mId");
14
if (deliveryId != null && messageId != null) {
15
Map<String,String> trackInfo = new HashMap<>();
16
trackInfo.put("_mId", messageId);
17
trackInfo.put("_dId", deliveryId);
18
19
// Send the tracking information for message opening
20
CampaignClassic.trackNotificationClick(trackInfo);
21
}
22
}
23
}
Copied!
Adobe Campaign Classic has not yet been released as an AEP 3.x Swift extension. Please reach out to your Adobe customer account manager if you have any questions or would like to express interest in the AEP 3.x Campaign Classic extension.
You can pass the launchOptions that were received upon opening the application or userInfo, which contains the received push payload in trackInfo. If trackInfo is null or does not contain the necessary tracking identifiers, broadlogId (_mId) and deliveryId (_dId), a track request is not sent.

Swift

Syntax
1
func trackNotificationClick(_ trackInfo: [String: String])
Copied!
Example
1
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
2
guard let userInfo = response.notification.request.content.userInfo as? [String: String] else {
3
return;
4
}
5
ACPCampaignClassic.trackNotificationClick(userInfo);
6
completionHandler();
7
}
Copied!

Objective-C

Syntax
1
+ (void) trackNotificationClick: (nonnull NSDictionary<NSString*, NSString*>*) trackInfo;
Copied!
Example
1
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler
2
{
3
NSLog(@"User Info : %@",response.notification.request.content.userInfo);
4
// Track action selected by the user for a given notification
5
[ACPCampaignClassic trackNotificationClick:response.notification.request.content.userInfo];
6
completionHandler();
7
}
Copied!

trackNotificationReceive

The trackNotificationReceive API sends the received push notification's tracking information to the configured Adobe Campaign Classic server.
Android
iOS (AEP 3.x)
iOS (ACP 2.x)

Java

If trackInfo is null or does not contain the necessary tracking identifiers, messageId (_mId) and deliveryId (_dId), a track request is not sent.
Syntax
1
public static void trackNotificationReceive(final Map<String, String> trackInfo)
Copied!
Example
1
public class MyFirebaseMessagingService extends FirebaseMessagingService {
2
@Override
3
public void onMessageReceived(RemoteMessage remoteMessage) {
4
Log.d("TestApp", "Receive message from: " + remoteMessage.getFrom());
5
Map<String,String> payloadData = message.getData();
6
7
// Check if message contains data payload.
8
if (payloadData.size() > 0) {
9
Map<String,String> trackInfo = new HashMap<>();
10
trackInfo.put("_mId", payloadData.get("_mId"));
11
trackInfo.put("_dId", payloadData.get("_dId"));
12
13
// Send the tracking information for message received
14
CampaignClassic.trackNotificationReceive(trackInfo);
15
}
16
}
17
}
Copied!
Adobe Campaign Classic has not yet been released as an AEP 3.x Swift extension. Please reach out to your Adobe customer account manager if you have any questions or would like to express interest in the AEP 3.x Campaign Classic extension.
You can pass the launchOptions that were received upon opening the application or userInfo , which contains the received push payload in trackInfo. If trackInfo is null or does not contain the necessary tracking identifiers, broadlogId (_mId) and deliveryId (_dId), a track request is not sent.

Swift

Syntax
1
func trackNotificationReceive(_ trackInfo: [String: String])
Copied!
Example
1
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
2
3
guard let aps = userInfo["aps"] as? [String: Any] else {
4
completionHandler(.failed)
5
return
6
}
7
if aps["content-available"] as? Int == 1 {
8
// Track silent push notification receive
9
ACPCampaignClassic.trackNotificationReceive(userInfo)
10
completionHandler(.noData)
11
}
12
}
Copied!

Objective-C

Syntax
1
+ (void) trackNotificationReceive: (nonnull NSDictionary<NSString*, NSString*>*) trackInfo;
Copied!
Example
1
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)launchOptions fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
2
{
3
if ( launchOptions) NSLog(@"launchOptions: %@", [launchOptions description]);
4
// Tracking silent push notification receive
5
if ( [launchOptions[@"aps"][@"content-available"] intValue] == 1 ) {
6
NSLog(@"Silent Push Notification");
7
[ACPCampaignClassic trackNotificationReceive:launchOptions];
8
completionHandler(UIBackgroundFetchResultNoData);
9
}
10
}
Copied!