Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions AdobeBranchExtension.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Pod::Spec.new do |s|

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

s.dependency 'AEPCore', '~> 5.1.0'
s.dependency 'AEPLifecycle', '~> 5.1.0'
s.dependency 'AEPIdentity', '~> 5.1.0'
s.dependency 'AEPSignal', '~> 5.1.0'
s.dependency 'BranchSDK', '~> 3.13.3'
s.dependency 'BranchSDK', '~> 3.13.3'
s.dependency 'AEPCore', '~> 5.7.0'
s.dependency 'AEPEdge', '~> 5.0'
s.dependency 'AEPEdgeIdentity', '~> 5.0'

end
53 changes: 30 additions & 23 deletions AdobeBranchExtension/Classes/AdobeBranchExtensionClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#import <BranchSDK/BranchPluginSupport.h>
#import <BranchSDK/BranchEvent.h>

@import AEPCore;
@import AEPEdge;
@import AEPEdgeIdentity;

#pragma mark Constants

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

NSString *const EXPERIENCE_CLOUD_ID_KEY = @"ECID";

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

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

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

- (void) trackEvent:(AEPEvent*)event {
[[BranchLogger shared] logVerbose: @"trackEvent" error:nil];

NSString *eventName = getEventNameFromEvent(event);

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


- (BOOL)isValidEventForBranch:(NSString*)eventName {
[[BranchLogger shared] logVerbose: @"isValidEventForBranch" error:nil];

if ([AdobeBranchExtensionConfig instance].exclusionList.count == 0 && [AdobeBranchExtensionConfig instance].allowList.count == 0) {
return YES;
} else if ([AdobeBranchExtensionConfig instance].allowList.count != 0 && [[AdobeBranchExtensionConfig instance].allowList containsObject: eventName]) {
Expand All @@ -328,34 +341,28 @@ - (BOOL)isValidEventForBranch:(NSString*)eventName {
}

- (void) passAdobeIdsToBranch:(AEPEvent*)eventToProcess {
NSError *error = nil;

AEPSharedStateResult *configSharedState = [self.runtime getSharedStateWithExtensionName:eventToProcess.data[ABEAdobeEventDataKey_StateOwner] event:eventToProcess barrier:NO];

if (!configSharedState.value) {
[[BranchLogger shared] logWarning: @"BranchSDK_ Could not process event, configuration shared state is pending" error:nil];
return;
}
if (error) {
[[BranchLogger shared] logWarning: @"BranchSDK_ Could not process event, an error occured while retrieving configuration shared state" error:nil];
return;
}
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Configuration shared state value: %@", configSharedState.value] error:nil];

Branch *branch = [Branch getInstance];
for (id key in configSharedState.value.allKeys) {

NSString *idAsString = [NSString stringWithFormat:@"%@", [configSharedState.value objectForKey:key]];

[AEPMobileEdgeIdentity getExperienceCloudId:^(NSString * _Nullable ecid, NSError * _Nullable error) {

if (!idAsString || [idAsString isEqualToString:@""]) continue;
// Check for an error
if (error) {
[[BranchLogger shared] logError:@"Error getting ECID." error:error];
return;
}

if ([key isEqualToString:@"mid"]) {
[branch setRequestMetadataKey:@"$marketing_cloud_visitor_id" value:idAsString];
} else if ([key isEqualToString:@"vid"]) {
[branch setRequestMetadataKey:@"$analytics_visitor_id" value:idAsString];
} else if ([key isEqualToString:@"aid"]) {
[branch setRequestMetadataKey:@"$adobe_visitor_id" value:idAsString];
// Check if the ECID is nil or empty
if (!ecid || [ecid length] == 0) {
[[BranchLogger shared] logVerbose:@"ECID was nil or empty." error:nil];
return;
}
}

[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"ECID retrieved: %@", ecid] error:nil];
[branch setRequestMetadataKey:@"$marketing_cloud_visitor_id" value:ecid];
}];
}

- (void) deviceDataSharedState: (nullable AEPEvent*) event {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

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

/* Begin PBXFileReference section */
Expand All @@ -36,10 +36,10 @@
4DE097FC219CEABE008AC401 /* Products.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = Products.json; sourceTree = "<group>"; };
4DE097FE219CEE71008AC401 /* Product.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Product.h; sourceTree = "<group>"; };
4DE097FF219CEE71008AC401 /* Product.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Product.m; sourceTree = "<group>"; };
4EDC2BD748B9BA3657AEDAC0 /* Pods_AdobeBranchExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AdobeBranchExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
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>"; };
5FF9D44421FA692500A73E56 /* libACPCoreBeta.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libACPCoreBeta.a; sourceTree = BUILT_PRODUCTS_DIR; };
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>"; };
81481EB04B844AEA5F3350DF /* Pods_AdobeBranchExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AdobeBranchExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
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>"; };
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>"; };
AC21DF76215AA0EB00CD5DAC /* ProductViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProductViewController.h; sourceTree = "<group>"; };
AC21DF77215AA0EB00CD5DAC /* ProductViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProductViewController.m; sourceTree = "<group>"; };
ACAE8104212263F30049505B /* AdobeBranchExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AdobeBranchExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -78,7 +78,7 @@
ACAE812F2122644F0049505B /* libz.tbd in Frameworks */,
ACAE812D212264480049505B /* libstdc++.tbd in Frameworks */,
ACAE812B2122643A0049505B /* libsqlite3.tbd in Frameworks */,
441ADFCD9CBD0E558A2E656E /* Pods_AdobeBranchExample.framework in Frameworks */,
F421ADEAFBAD6A1682A0053D /* Pods_AdobeBranchExample.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -88,8 +88,8 @@
73C43ADAEA57DC95575EA85A /* Pods */ = {
isa = PBXGroup;
children = (
728AA9B162BA975B15BBF89D /* Pods-AdobeBranchExample.debug.xcconfig */,
8CEC8A00B3D73770FD160018 /* Pods-AdobeBranchExample.release.xcconfig */,
4F34E31C23FE8CD0A876A741 /* Pods-AdobeBranchExample.debug.xcconfig */,
8149E143F88C02D4A57CC272 /* Pods-AdobeBranchExample.release.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
Expand Down Expand Up @@ -153,7 +153,7 @@
ACAE812E2122644E0049505B /* libz.tbd */,
ACAE812C212264480049505B /* libstdc++.tbd */,
ACAE812A2122643A0049505B /* libsqlite3.tbd */,
81481EB04B844AEA5F3350DF /* Pods_AdobeBranchExample.framework */,
4EDC2BD748B9BA3657AEDAC0 /* Pods_AdobeBranchExample.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand All @@ -165,11 +165,11 @@
isa = PBXNativeTarget;
buildConfigurationList = ACAE811A212263F40049505B /* Build configuration list for PBXNativeTarget "AdobeBranchExample" */;
buildPhases = (
9F90F9B58CF53C25C1376EE5 /* [CP] Check Pods Manifest.lock */,
E3C17F443A526E8FE943A86F /* [CP] Check Pods Manifest.lock */,
ACAE8100212263F30049505B /* Sources */,
ACAE8101212263F30049505B /* Frameworks */,
ACAE8102212263F30049505B /* Resources */,
1FC8ABE38F6AFE5B082C8266 /* [CP] Embed Pods Frameworks */,
A658D26F78BD84EBB52DA403 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -234,7 +234,7 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
1FC8ABE38F6AFE5B082C8266 /* [CP] Embed Pods Frameworks */ = {
A658D26F78BD84EBB52DA403 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand All @@ -251,7 +251,7 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AdobeBranchExample/Pods-AdobeBranchExample-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9F90F9B58CF53C25C1376EE5 /* [CP] Check Pods Manifest.lock */ = {
E3C17F443A526E8FE943A86F /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand Down Expand Up @@ -417,7 +417,7 @@
};
ACAE811B212263F40049505B /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 728AA9B162BA975B15BBF89D /* Pods-AdobeBranchExample.debug.xcconfig */;
baseConfigurationReference = 4F34E31C23FE8CD0A876A741 /* Pods-AdobeBranchExample.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AdobeBranchExample/AdobeBranchExample.entitlements;
Expand All @@ -439,7 +439,7 @@
};
ACAE811C212263F40049505B /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 8CEC8A00B3D73770FD160018 /* Pods-AdobeBranchExample.release.xcconfig */;
baseConfigurationReference = 8149E143F88C02D4A57CC272 /* Pods-AdobeBranchExample.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AdobeBranchExample/AdobeBranchExample.entitlements;
Expand Down
40 changes: 29 additions & 11 deletions Examples/AdobeBranchExample/AdobeBranchExample/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@

#import "AppDelegate.h"

@import AEPCore;
@import AEPSignal;
@import AEPLifecycle;
@import AEPIdentity;
@import AEPUserProfile;
@import AEPEdge;
@import AEPEdgeIdentity;
@import AEPServices;
@import AEPAnalytics;

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

Expand All @@ -48,16 +45,37 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}
}];

[AEPMobileAnalytics setVisitorIdentifier:@"custom_identifier_bb"];// for testing passAdobeIdsToBranch method
//[AEPMobileAnalytics setVisitorIdentifier:@"custom_identifier_bb"];// for testing passAdobeIdsToBranch method
//Becomes ->

NSString *MY_ID_NAMESPACE = @"custom_namespace";
NSString *MY_ID_VALUE = @"custom_identifier_bb2";

AEPIdentityItem *identityItem = [[AEPIdentityItem alloc] initWithId:MY_ID_VALUE
authenticatedState:AEPAuthenticatedStateAuthenticated
primary:NO];

AEPIdentityMap *identityMap = [[AEPIdentityMap alloc] init];
[identityMap addItem:identityItem withNamespace:MY_ID_NAMESPACE];

// 4. Call updateIdentities to send the ID to the Edge Network
[AEPMobileEdgeIdentity updateIdentities:identityMap];

const UIApplicationState appState = application.applicationState;

[AEPMobileCore setLogLevel: AEPLogLevelDebug];


// register AEPCore
if ((YES)) {
// option 1 - access hosted Adobe config

[AEPMobileCore registerExtensions:@[AEPMobileSignal.class, AEPMobileLifecycle.class, AEPMobileUserProfile.class, AEPMobileIdentity.class, AEPMobileAnalytics.class, AdobeBranchExtension.class] completion:^{
NSArray *extensionsToRegister = @[AEPMobileCore.self,
AEPMobileEdge.self,
AEPMobileEdgeIdentity.self,
AdobeBranchExtension.self];

[AEPMobileCore registerExtensions:extensionsToRegister completion:^{
[[BranchLogger shared] logDebug:@"registerExtensions:extensionsToRegister" error:nil];
// Configuration setup
[AEPMobileCore configureWithAppId: @"d10f76259195/c769149ebd48/launch-f972d1367b58-development"];//Adobe Launch property: "iOS Test"
if (appState != UIApplicationStateBackground) {
// only start lifecycle if the application is not in the background
Expand Down
11 changes: 6 additions & 5 deletions Examples/AdobeBranchExample/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ target 'AdobeBranchExample' do
use_frameworks!

pod 'BranchSDK'
pod 'AEPCore'

pod 'AEPCore', '~> 5.0'
pod 'AEPEdge'
pod 'AEPEdgeIdentity'
pod 'AEPLifecycle'
pod 'AEPIdentity'
pod 'AEPSignal'
pod 'AEPAnalytics'
pod 'AEPUserProfile'
pod 'AEPServices'


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