adjust-icon

iOS Adobe Extension example implementation

This page contains a full example implementation of the Adjust iOS Extension for Adobe Experience SDK.

You can see the full example on GitHub.

AppDelegate.h
//
// AppDelegate.h
// AdjustAdobeExtensionApp
//
// Created by Adjust SDK Team on 21.11.23.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@end
AppDelegate.m
//
// AppDelegate.m
// AdjustAdobeExtensionApp
//
// Created by Adjust SDK Team on 21.11.23.
//
#import "AppDelegate.h"
@import AEPCore;
@import AEPServices;
#import <AdjustAdobeExtension/AdjustAdobeExtension.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[AEPMobileCore setLogLevel: AEPLogLevelTrace];
const UIApplicationState appState = application.applicationState;
// Adjust Adobe Extension configuration
AdjustAdobeExtensionConfig *adjustConfig = [AdjustAdobeExtensionConfig configWithEnvironment:ADJEnvironmentSandbox];
[adjustConfig setAttributionChangedBlock:^(ADJAttribution * _Nullable attribution) {
NSLog(@"Adjust Attribution Callback received:[%@]", attribution.description);
}];
[adjustConfig setDeferredDeeplinkReceivedBlock:^BOOL(NSURL * _Nullable deeplink) {
NSLog(@"Adjust Deferred Deeplink received:[%@]", deeplink.absoluteString);
return YES;
}];
[adjustConfig setExternalDeviceId:@"external-device-id"];
[adjustConfig setDefaultTracker:@"default-tracker"];
[AdjustAdobeExtension setConfiguration:adjustConfig];
// Adjust Adobe Extension registration
[AEPMobileCore registerExtensions:@[AdjustAdobeExtension.class]
completion:^{
//Adobe Launch property: "iOS Test"
[AEPMobileCore configureWithAppId: @"89645c501ce0/540de252943f/launch-f8d889dd15b6-development"];
if (appState != UIApplicationStateBackground) {
// only start lifecycle if the application is not in the background
[AEPMobileCore lifecycleStart:nil];
}
}];
return YES;
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
NSLog(@"Scheme based deep link opened an app: %@", url);
// Call the below method to send deep link to Adjust backend
[Adjust processDeeplink:[[ADJDeeplink alloc] initWithDeeplink:url]];
return YES;
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
if ([[userActivity activityType] isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSLog(@"Universal link opened an app: %@", [userActivity webpageURL]);
// Pass deep link to Adjust in order to potentially reattribute user.
[Adjust processDeeplink:[[ADJDeeplink alloc] initWithDeeplink:[userActivity webpageURL]]];
}
return YES;
}
#pragma mark - UISceneSession lifecycle
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}
- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
@end
ViewController.h
//
// ViewController.h
// AdjustAdobeExtensionApp
//
// Created by Adjust SDK Team on 21.11.23.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
ViewController.m
//
// ViewController.m
// AdjustAdobeExtensionApp
//
// Created by Adjust SDK Team on 21.11.23.
//
#import "ViewController.h"
@import AEPCore;
#import <AdjustAdobeExtension/AdjustAdobeExtension.h>
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Add Global Partner Parameters
[Adjust addGlobalPartnerParameter:@"value1" forKey:@"key1"];
[Adjust addGlobalPartnerParameter:@"value2" forKey:@"key2"];
// Add Global Callback Parameters
[Adjust addGlobalCallbackParameter:@"value1" forKey:@"key1"];
[Adjust addGlobalCallbackParameter:@"value2" forKey:@"key2"];
// Track simple event
NSMutableDictionary * dataDict = [NSMutableDictionary dictionary];
[dataDict setValue:@"g3mfiw" forKey:ADJAdobeAdjustEventToken];
[AEPMobileCore trackAction:ADJAdobeAdjustActionTrackEvent
data:dataDict];
[dataDict removeAllObjects];
// Track Revenue event
[dataDict setValue:@"a4fd35" forKey:ADJAdobeAdjustEventToken];
[dataDict setValue:@"1.0" forKey:ADJAdobeAdjustEventRevenue];
[dataDict setValue:@"EUR" forKey:ADJAdobeAdjustEventCurrency];
[AEPMobileCore trackAction:ADJAdobeAdjustActionTrackEvent
data:dataDict];
[dataDict removeAllObjects];
// Track event with Callback parameters
[dataDict setValue:@"34vgg9" forKey:ADJAdobeAdjustEventToken];
[dataDict setValue:@"value1" forKey:[ADJAdobeAdjustEventCallbackParamPrefix stringByAppendingString:@"key1"]];
[dataDict setValue:@"value2" forKey:[ADJAdobeAdjustEventCallbackParamPrefix stringByAppendingString:@"key2"]];
[AEPMobileCore trackAction:ADJAdobeAdjustActionTrackEvent
data:dataDict];
[dataDict removeAllObjects];
// Track event with Partner parameters
[dataDict setValue:@"w788qs" forKey:ADJAdobeAdjustEventToken];
[dataDict setValue:@"value1" forKey:[ADJAdobeAdjustEventPartnerParamPrefix stringByAppendingString:@"key1"]];
[dataDict setValue:@"value2" forKey:[ADJAdobeAdjustEventPartnerParamPrefix stringByAppendingString:@"key2"]];
[AEPMobileCore trackAction:ADJAdobeAdjustActionTrackEvent
data:dataDict];
[dataDict removeAllObjects];
// Set Push Token
[dataDict setValue:@"your_app_push_token" forKey:ADJAdobeAdjustPushToken];
[AEPMobileCore trackAction:ADJAdobeAdjustActionSetPushToken
data:dataDict];
[dataDict removeAllObjects];
}
@end