Skip to content

Commit 8d60ec6

Browse files
Migrate to latest Adobe SDKs
1 parent 333fda7 commit 8d60ec6

File tree

5 files changed

+84
-58
lines changed

5 files changed

+84
-58
lines changed

AdobeBranchExtension.podspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ Pod::Spec.new do |s|
2222

2323
s.source_files = 'AdobeBranchExtension/Classes/**/*'
2424

25-
s.dependency 'AEPCore', '~> 5.1.0'
26-
s.dependency 'AEPLifecycle', '~> 5.1.0'
27-
s.dependency 'AEPIdentity', '~> 5.1.0'
28-
s.dependency 'AEPSignal', '~> 5.1.0'
29-
s.dependency 'BranchSDK', '~> 3.13.3'
25+
s.dependency 'BranchSDK', '~> 3.13.3'
26+
s.dependency 'AEPCore', '~> 5.7.0'
27+
s.dependency 'AEPEdge', '~> 5.0'
28+
s.dependency 'AEPEdgeIdentity', '~> 5.0'
29+
3030
end

AdobeBranchExtension/Classes/AdobeBranchExtensionClass.m

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#import <BranchSDK/BranchPluginSupport.h>
1414
#import <BranchSDK/BranchEvent.h>
1515

16+
@import AEPCore;
17+
@import AEPEdge;
18+
@import AEPEdgeIdentity;
19+
1620
#pragma mark Constants
1721

1822
// Branch events type and source
@@ -28,10 +32,11 @@
2832
// 2. whose owner (i.e. extension/module) retrieved with this key from event data
2933
NSString *const ABEAdobeEventDataKey_StateOwner = @"stateowner";
3034
// 3. is either
31-
NSString *const ABEAdobeIdentityExtension = @"com.adobe.module.identity";
35+
NSString *const ABEAdobeIdentityExtension = @"com.adobe.edge.identity";
3236
NSString *const ABEAdobeAnalyticsExtension = @"com.adobe.module.analytics";
3337
// 4. will contain Adobe ID values needed to be passed to Branch prior to session initialization
3438

39+
NSString *const EXPERIENCE_CLOUD_ID_KEY = @"ECID";
3540

3641
@interface AdobeBranchExtension()
3742
@end
@@ -165,6 +170,10 @@ + (BOOL)configureEventAllowList:(nullable NSArray<NSString *> *)eventNames error
165170

166171
- (void)handleEvent:(AEPEvent*)event {
167172
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Handling Event: %@", event] error:nil];
173+
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Handling Event Type: %@", event.source] error:nil];
174+
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Handling Event Source: %@", event.type] error:nil];
175+
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Adobe Branch Extension Event Types: %@", [AdobeBranchExtensionConfig instance].eventTypes] error:nil];
176+
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Adobe Branch Extension Event Sources: %@", [AdobeBranchExtensionConfig instance].eventSources] error:nil];
168177

169178
if ([[AdobeBranchExtensionConfig instance].eventTypes containsObject:event.type] &&
170179
[[AdobeBranchExtensionConfig instance].eventSources containsObject:event.source]) {
@@ -262,6 +271,8 @@ + (BranchEvent *)branchEventFromAdobeEventName:(NSString *)eventName
262271
}
263272

264273
- (void) trackEvent:(AEPEvent*)event {
274+
[[BranchLogger shared] logVerbose: @"trackEvent" error:nil];
275+
265276
NSString *eventName = getEventNameFromEvent(event);
266277

267278
if (!eventName.length) return;
@@ -317,6 +328,8 @@ - (void) trackEvent:(AEPEvent*)event {
317328

318329

319330
- (BOOL)isValidEventForBranch:(NSString*)eventName {
331+
[[BranchLogger shared] logVerbose: @"isValidEventForBranch" error:nil];
332+
320333
if ([AdobeBranchExtensionConfig instance].exclusionList.count == 0 && [AdobeBranchExtensionConfig instance].allowList.count == 0) {
321334
return YES;
322335
} else if ([AdobeBranchExtensionConfig instance].allowList.count != 0 && [[AdobeBranchExtensionConfig instance].allowList containsObject: eventName]) {
@@ -328,34 +341,28 @@ - (BOOL)isValidEventForBranch:(NSString*)eventName {
328341
}
329342

330343
- (void) passAdobeIdsToBranch:(AEPEvent*)eventToProcess {
331-
NSError *error = nil;
332-
333344
AEPSharedStateResult *configSharedState = [self.runtime getSharedStateWithExtensionName:eventToProcess.data[ABEAdobeEventDataKey_StateOwner] event:eventToProcess barrier:NO];
334-
335-
if (!configSharedState.value) {
336-
[[BranchLogger shared] logWarning: @"BranchSDK_ Could not process event, configuration shared state is pending" error:nil];
337-
return;
338-
}
339-
if (error) {
340-
[[BranchLogger shared] logWarning: @"BranchSDK_ Could not process event, an error occured while retrieving configuration shared state" error:nil];
341-
return;
342-
}
345+
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Configuration shared state value: %@", configSharedState.value] error:nil];
343346

344347
Branch *branch = [Branch getInstance];
345-
for (id key in configSharedState.value.allKeys) {
346-
347-
NSString *idAsString = [NSString stringWithFormat:@"%@", [configSharedState.value objectForKey:key]];
348+
349+
[AEPMobileEdgeIdentity getExperienceCloudId:^(NSString * _Nullable ecid, NSError * _Nullable error) {
348350

349-
if (!idAsString || [idAsString isEqualToString:@""]) continue;
351+
// Check for an error
352+
if (error) {
353+
[[BranchLogger shared] logError:@"Error getting ECID." error:error];
354+
return;
355+
}
350356

351-
if ([key isEqualToString:@"mid"]) {
352-
[branch setRequestMetadataKey:@"$marketing_cloud_visitor_id" value:idAsString];
353-
} else if ([key isEqualToString:@"vid"]) {
354-
[branch setRequestMetadataKey:@"$analytics_visitor_id" value:idAsString];
355-
} else if ([key isEqualToString:@"aid"]) {
356-
[branch setRequestMetadataKey:@"$adobe_visitor_id" value:idAsString];
357+
// Check if the ECID is nil or empty
358+
if (!ecid || [ecid length] == 0) {
359+
[[BranchLogger shared] logVerbose:@"ECID was nil or empty." error:nil];
360+
return;
357361
}
358-
}
362+
363+
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"ECID retrieved: %@", ecid] error:nil];
364+
[branch setRequestMetadataKey:@"$marketing_cloud_visitor_id" value:ecid];
365+
}];
359366
}
360367

361368
- (void) deviceDataSharedState: (nullable AEPEvent*) event {

Examples/AdobeBranchExample/AdobeBranchExample.xcodeproj/project.pbxproj

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
/* Begin PBXBuildFile section */
1010
3B020CCC2E6B2F050088A3C7 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 3B020CCB2E6B2F050088A3C7 /* PrivacyInfo.xcprivacy */; };
11-
441ADFCD9CBD0E558A2E656E /* Pods_AdobeBranchExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81481EB04B844AEA5F3350DF /* Pods_AdobeBranchExample.framework */; };
1211
4D16DBA421AF037F00E362A2 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4D16DBA321AF037F00E362A2 /* Launch Screen.storyboard */; };
1312
4D16DBA721AF5B6300E362A2 /* TextViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D16DBA621AF5B6300E362A2 /* TextViewController.m */; };
1413
4DE097FD219CEABE008AC401 /* Products.json in Resources */ = {isa = PBXBuildFile; fileRef = 4DE097FC219CEABE008AC401 /* Products.json */; };
@@ -26,6 +25,7 @@
2625
ACAE81332122645B0049505B /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ACAE81322122645B0049505B /* UserNotifications.framework */; };
2726
ACAE8135212264610049505B /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ACAE8134212264610049505B /* SystemConfiguration.framework */; };
2827
C10F392A278E39AD00BF5D36 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C10F3929278E39AD00BF5D36 /* AdSupport.framework */; };
28+
F421ADEAFBAD6A1682A0053D /* Pods_AdobeBranchExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4EDC2BD748B9BA3657AEDAC0 /* Pods_AdobeBranchExample.framework */; };
2929
/* End PBXBuildFile section */
3030

3131
/* Begin PBXFileReference section */
@@ -36,10 +36,10 @@
3636
4DE097FC219CEABE008AC401 /* Products.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = Products.json; sourceTree = "<group>"; };
3737
4DE097FE219CEE71008AC401 /* Product.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Product.h; sourceTree = "<group>"; };
3838
4DE097FF219CEE71008AC401 /* Product.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Product.m; sourceTree = "<group>"; };
39+
4EDC2BD748B9BA3657AEDAC0 /* Pods_AdobeBranchExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AdobeBranchExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
40+
4F34E31C23FE8CD0A876A741 /* Pods-AdobeBranchExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AdobeBranchExample.debug.xcconfig"; path = "Target Support Files/Pods-AdobeBranchExample/Pods-AdobeBranchExample.debug.xcconfig"; sourceTree = "<group>"; };
3941
5FF9D44421FA692500A73E56 /* libACPCoreBeta.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libACPCoreBeta.a; sourceTree = BUILT_PRODUCTS_DIR; };
40-
728AA9B162BA975B15BBF89D /* Pods-AdobeBranchExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AdobeBranchExample.debug.xcconfig"; path = "Target Support Files/Pods-AdobeBranchExample/Pods-AdobeBranchExample.debug.xcconfig"; sourceTree = "<group>"; };
41-
81481EB04B844AEA5F3350DF /* Pods_AdobeBranchExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AdobeBranchExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
42-
8CEC8A00B3D73770FD160018 /* Pods-AdobeBranchExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AdobeBranchExample.release.xcconfig"; path = "Target Support Files/Pods-AdobeBranchExample/Pods-AdobeBranchExample.release.xcconfig"; sourceTree = "<group>"; };
42+
8149E143F88C02D4A57CC272 /* Pods-AdobeBranchExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AdobeBranchExample.release.xcconfig"; path = "Target Support Files/Pods-AdobeBranchExample/Pods-AdobeBranchExample.release.xcconfig"; sourceTree = "<group>"; };
4343
AC21DF76215AA0EB00CD5DAC /* ProductViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProductViewController.h; sourceTree = "<group>"; };
4444
AC21DF77215AA0EB00CD5DAC /* ProductViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProductViewController.m; sourceTree = "<group>"; };
4545
ACAE8104212263F30049505B /* AdobeBranchExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AdobeBranchExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -78,7 +78,7 @@
7878
ACAE812F2122644F0049505B /* libz.tbd in Frameworks */,
7979
ACAE812D212264480049505B /* libstdc++.tbd in Frameworks */,
8080
ACAE812B2122643A0049505B /* libsqlite3.tbd in Frameworks */,
81-
441ADFCD9CBD0E558A2E656E /* Pods_AdobeBranchExample.framework in Frameworks */,
81+
F421ADEAFBAD6A1682A0053D /* Pods_AdobeBranchExample.framework in Frameworks */,
8282
);
8383
runOnlyForDeploymentPostprocessing = 0;
8484
};
@@ -88,8 +88,8 @@
8888
73C43ADAEA57DC95575EA85A /* Pods */ = {
8989
isa = PBXGroup;
9090
children = (
91-
728AA9B162BA975B15BBF89D /* Pods-AdobeBranchExample.debug.xcconfig */,
92-
8CEC8A00B3D73770FD160018 /* Pods-AdobeBranchExample.release.xcconfig */,
91+
4F34E31C23FE8CD0A876A741 /* Pods-AdobeBranchExample.debug.xcconfig */,
92+
8149E143F88C02D4A57CC272 /* Pods-AdobeBranchExample.release.xcconfig */,
9393
);
9494
path = Pods;
9595
sourceTree = "<group>";
@@ -153,7 +153,7 @@
153153
ACAE812E2122644E0049505B /* libz.tbd */,
154154
ACAE812C212264480049505B /* libstdc++.tbd */,
155155
ACAE812A2122643A0049505B /* libsqlite3.tbd */,
156-
81481EB04B844AEA5F3350DF /* Pods_AdobeBranchExample.framework */,
156+
4EDC2BD748B9BA3657AEDAC0 /* Pods_AdobeBranchExample.framework */,
157157
);
158158
name = Frameworks;
159159
sourceTree = "<group>";
@@ -165,11 +165,11 @@
165165
isa = PBXNativeTarget;
166166
buildConfigurationList = ACAE811A212263F40049505B /* Build configuration list for PBXNativeTarget "AdobeBranchExample" */;
167167
buildPhases = (
168-
9F90F9B58CF53C25C1376EE5 /* [CP] Check Pods Manifest.lock */,
168+
E3C17F443A526E8FE943A86F /* [CP] Check Pods Manifest.lock */,
169169
ACAE8100212263F30049505B /* Sources */,
170170
ACAE8101212263F30049505B /* Frameworks */,
171171
ACAE8102212263F30049505B /* Resources */,
172-
1FC8ABE38F6AFE5B082C8266 /* [CP] Embed Pods Frameworks */,
172+
A658D26F78BD84EBB52DA403 /* [CP] Embed Pods Frameworks */,
173173
);
174174
buildRules = (
175175
);
@@ -234,7 +234,7 @@
234234
/* End PBXResourcesBuildPhase section */
235235

236236
/* Begin PBXShellScriptBuildPhase section */
237-
1FC8ABE38F6AFE5B082C8266 /* [CP] Embed Pods Frameworks */ = {
237+
A658D26F78BD84EBB52DA403 /* [CP] Embed Pods Frameworks */ = {
238238
isa = PBXShellScriptBuildPhase;
239239
buildActionMask = 2147483647;
240240
files = (
@@ -251,7 +251,7 @@
251251
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AdobeBranchExample/Pods-AdobeBranchExample-frameworks.sh\"\n";
252252
showEnvVarsInLog = 0;
253253
};
254-
9F90F9B58CF53C25C1376EE5 /* [CP] Check Pods Manifest.lock */ = {
254+
E3C17F443A526E8FE943A86F /* [CP] Check Pods Manifest.lock */ = {
255255
isa = PBXShellScriptBuildPhase;
256256
buildActionMask = 2147483647;
257257
files = (
@@ -417,7 +417,7 @@
417417
};
418418
ACAE811B212263F40049505B /* Debug */ = {
419419
isa = XCBuildConfiguration;
420-
baseConfigurationReference = 728AA9B162BA975B15BBF89D /* Pods-AdobeBranchExample.debug.xcconfig */;
420+
baseConfigurationReference = 4F34E31C23FE8CD0A876A741 /* Pods-AdobeBranchExample.debug.xcconfig */;
421421
buildSettings = {
422422
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
423423
CODE_SIGN_ENTITLEMENTS = AdobeBranchExample/AdobeBranchExample.entitlements;
@@ -439,7 +439,7 @@
439439
};
440440
ACAE811C212263F40049505B /* Release */ = {
441441
isa = XCBuildConfiguration;
442-
baseConfigurationReference = 8CEC8A00B3D73770FD160018 /* Pods-AdobeBranchExample.release.xcconfig */;
442+
baseConfigurationReference = 8149E143F88C02D4A57CC272 /* Pods-AdobeBranchExample.release.xcconfig */;
443443
buildSettings = {
444444
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
445445
CODE_SIGN_ENTITLEMENTS = AdobeBranchExample/AdobeBranchExample.entitlements;

Examples/AdobeBranchExample/AdobeBranchExample/AppDelegate.m

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@
88

99
#import "AppDelegate.h"
1010

11-
@import AEPCore;
12-
@import AEPSignal;
13-
@import AEPLifecycle;
14-
@import AEPIdentity;
15-
@import AEPUserProfile;
11+
@import AEPEdge;
12+
@import AEPEdgeIdentity;
1613
@import AEPServices;
17-
@import AEPAnalytics;
1814

1915
#import "ProductViewController.h"
2016
#import "AdobeBranchExtension.h"
@@ -30,7 +26,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3026
// initialize Branch session, [AdobeBranchExtension initSessionWithLaunchOptions] is different from
3127
// [[Branch getInstance] initSessionWithLaunchOptions] in that it holds up initialization in order to collect
3228
// Adobe IDs and pass them to Branch as request metadata, see [AdobeBranchExtension delayInitSessionToCollectAdobeIDs]
33-
[Branch enableLogging];
29+
[AEPMobileCore setLogLevel: AEPLogLevelDebug];
30+
[Branch enableLoggingAtLevel:BranchLogLevelVerbose withCallback:nil];
3431
[AdobeBranchExtension initSessionWithLaunchOptions:launchOptions andRegisterDeepLinkHandler:^(NSDictionary * _Nullable params, NSError * _Nullable error) {
3532
if (!error && params && [params[@"+clicked_branch_link"] boolValue]) {
3633

@@ -48,16 +45,37 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
4845
}
4946
}];
5047

51-
[AEPMobileAnalytics setVisitorIdentifier:@"custom_identifier_bb"];// for testing passAdobeIdsToBranch method
48+
//[AEPMobileAnalytics setVisitorIdentifier:@"custom_identifier_bb"];// for testing passAdobeIdsToBranch method
49+
//Becomes ->
50+
51+
NSString *MY_ID_NAMESPACE = @"custom_namespace";
52+
NSString *MY_ID_VALUE = @"custom_identifier_bb2";
53+
54+
AEPIdentityItem *identityItem = [[AEPIdentityItem alloc] initWithId:MY_ID_VALUE
55+
authenticatedState:AEPAuthenticatedStateAuthenticated
56+
primary:NO];
57+
58+
AEPIdentityMap *identityMap = [[AEPIdentityMap alloc] init];
59+
[identityMap addItem:identityItem withNamespace:MY_ID_NAMESPACE];
60+
61+
// 4. Call updateIdentities to send the ID to the Edge Network
62+
[AEPMobileEdgeIdentity updateIdentities:identityMap];
63+
5264
const UIApplicationState appState = application.applicationState;
5365

54-
[AEPMobileCore setLogLevel: AEPLogLevelDebug];
66+
5567

5668
// register AEPCore
5769
if ((YES)) {
5870
// option 1 - access hosted Adobe config
59-
60-
[AEPMobileCore registerExtensions:@[AEPMobileSignal.class, AEPMobileLifecycle.class, AEPMobileUserProfile.class, AEPMobileIdentity.class, AEPMobileAnalytics.class, AdobeBranchExtension.class] completion:^{
71+
NSArray *extensionsToRegister = @[AEPMobileCore.self,
72+
AEPMobileEdge.self,
73+
AEPMobileEdgeIdentity.self,
74+
AdobeBranchExtension.self];
75+
76+
[AEPMobileCore registerExtensions:extensionsToRegister completion:^{
77+
[[BranchLogger shared] logDebug:@"registerExtensions:extensionsToRegister" error:nil];
78+
// Configuration setup
6179
[AEPMobileCore configureWithAppId: @"d10f76259195/c769149ebd48/launch-f972d1367b58-development"];//Adobe Launch property: "iOS Test"
6280
if (appState != UIApplicationStateBackground) {
6381
// only start lifecycle if the application is not in the background

Examples/AdobeBranchExample/Podfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ target 'AdobeBranchExample' do
44
use_frameworks!
55

66
pod 'BranchSDK'
7-
pod 'AEPCore'
7+
8+
pod 'AEPCore', '~> 5.0'
9+
pod 'AEPEdge'
10+
pod 'AEPEdgeIdentity'
811
pod 'AEPLifecycle'
9-
pod 'AEPIdentity'
10-
pod 'AEPSignal'
11-
pod 'AEPAnalytics'
12-
pod 'AEPUserProfile'
12+
pod 'AEPServices'
13+
1314

1415
pod 'AdobeBranchExtension', :path => '../../'
1516
end

0 commit comments

Comments
 (0)