Skip to content

Commit a8f1655

Browse files
authored
Merge pull request #13 from BranchMetrics/staging
Staging
2 parents 7e1e0df + 4676181 commit a8f1655

File tree

8 files changed

+84
-16
lines changed

8 files changed

+84
-16
lines changed

AdobeBranchExtension.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "AdobeBranchExtension"
3-
s.version = "1.0.1"
3+
s.version = "1.1.0"
44
s.summary = "The Branch extension for Adobe Cloud Platform on iOS."
55

66
s.description = <<-DESC

AdobeBranchExtension/Classes/AdobeBranchExtensionClass.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ FOUNDATION_EXPORT NSString*const ABEBranchEventSource;
3434

3535
+ (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options;
3636

37+
+ (void)configureEventTypes:(nullable NSArray<NSString *> *)eventTypes andEventSources:(nullable NSArray<NSString *> *)eventSources;
38+
3739
- (void)handleEvent:(ACPExtensionEvent*)event;
3840

3941
@end

AdobeBranchExtension/Classes/AdobeBranchExtensionClass.m

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
//
88

99
#import "AdobeBranchExtension.h"
10+
#import "AdobeBranchExtensionConfig.h"
1011
#import <Branch/Branch.h>
1112

1213
#pragma mark Constants
1314

14-
NSString*const ABEBranchExtensionVersion = @"1.0.1";
15+
NSString*const ABEBranchExtensionVersion = @"1.1.0";
1516

1617
NSString*const ABEBranchEventType = @"com.branch.eventType";
1718
NSString*const ABEBranchEventSource = @"com.branch.eventSource";
@@ -67,17 +68,32 @@ + (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(N
6768
return [[self bnc_branchInstance] application:application openURL:url options:options];
6869
}
6970

71+
+ (void)configureEventTypes:(nullable NSArray<NSString *> *)eventTypes andEventSources:(nullable NSArray<NSString *> *)eventSources {
72+
if (eventTypes) {
73+
[AdobeBranchExtensionConfig instance].eventTypes = eventTypes;
74+
} else {
75+
[AdobeBranchExtensionConfig instance].eventTypes = @[];
76+
}
77+
78+
if (eventSources) {
79+
[AdobeBranchExtensionConfig instance].eventSources = eventSources;
80+
} else {
81+
[AdobeBranchExtensionConfig instance].eventSources = @[];
82+
}
83+
}
84+
7085
- (instancetype)init {
7186
self = [super init];
7287
if (!self) return self;
7388

7489
BNCLogSetDisplayLevel(BNCLogLevelError);
7590

7691
NSError *error = nil;
77-
if ([self.api registerWildcardListener:AdobeBranchExtensionListener.class error:&error])
92+
if ([self.api registerWildcardListener:AdobeBranchExtensionListener.class error:&error]) {
7893
BNCLogDebug(@"BranchExtensionRuleListener was registered.");
79-
else
94+
} else {
8095
BNCLogError(@"Can't register AdobeBranchExtensionRuleListener: %@.", error);
96+
}
8197
return self;
8298
}
8399

@@ -92,8 +108,8 @@ - (nullable NSString *)version {
92108
- (void)handleEvent:(ACPExtensionEvent*)event {
93109
BNCLogDebug(@"Event: %@", event);
94110

95-
if ([event.eventType isEqualToString:@"com.adobe.eventType.generic.track"] &&
96-
[event.eventSource isEqualToString:@"com.adobe.eventSource.requestContent"]) {
111+
if ([[AdobeBranchExtensionConfig instance].eventTypes containsObject:event.eventType] &&
112+
[[AdobeBranchExtensionConfig instance].eventSources containsObject:event.eventSource]) {
97113
[self trackEvent:event];
98114
return;
99115
}
@@ -126,7 +142,7 @@ - (void)handleEvent:(ACPExtensionEvent*)event {
126142
return dictionary;
127143
}
128144

129-
+ (BranchEvent *)branchEventFromAdbobeEventName:(NSString *)eventName
145+
+ (BranchEvent *)branchEventFromAdobeEventName:(NSString *)eventName
130146
dictionary:(NSDictionary *)dictionary {
131147

132148
if (eventName.length == 0) return nil;
@@ -186,7 +202,7 @@ - (void) trackEvent:(ACPExtensionEvent*)event {
186202
if (!eventName.length) eventName = eventData[@"state"];
187203
if (!eventName.length) return;
188204
NSDictionary *content = [eventData objectForKey:@"contextdata"];
189-
BranchEvent *branchEvent = [self.class branchEventFromAdbobeEventName:eventName dictionary:content];
205+
BranchEvent *branchEvent = [self.class branchEventFromAdobeEventName:eventName dictionary:content];
190206
[branchEvent logEvent];
191207
}
192208

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// AdobeBranchExtensionConfig.h
3+
// Pods
4+
//
5+
// Created by Ernest Cho on 4/11/19.
6+
//
7+
8+
#import <Foundation/Foundation.h>
9+
10+
NS_ASSUME_NONNULL_BEGIN
11+
12+
@interface AdobeBranchExtensionConfig : NSObject
13+
@property (nonatomic, strong, readwrite) NSArray<NSString *> *eventTypes;
14+
@property (nonatomic, strong, readwrite) NSArray<NSString *> *eventSources;
15+
16+
+ (AdobeBranchExtensionConfig *)instance;
17+
18+
@end
19+
20+
NS_ASSUME_NONNULL_END
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// AdobeBranchExtensionConfig.m
3+
// Pods
4+
//
5+
// Created by Ernest Cho on 4/11/19.
6+
//
7+
8+
#import "AdobeBranchExtensionConfig.h"
9+
10+
@implementation AdobeBranchExtensionConfig
11+
12+
+ (AdobeBranchExtensionConfig *)instance {
13+
static AdobeBranchExtensionConfig *config;
14+
static dispatch_once_t onceToken;
15+
dispatch_once(&onceToken, ^{
16+
config = [AdobeBranchExtensionConfig new];
17+
});
18+
return config;
19+
}
20+
21+
- (instancetype)init {
22+
self = [super init];
23+
if (self) {
24+
// default event type and source to track, client can override
25+
self.eventTypes = @[ @"com.adobe.eventType.generic.track" ];
26+
self.eventSources = @[ @"com.adobe.eventSource.requestContent" ];
27+
}
28+
return self;
29+
}
30+
31+
@end

Examples/AdobeBranchExample/AdobeBranchExample.xcodeproj/project.pbxproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,6 @@
398398
CODE_SIGN_IDENTITY = "iPhone Developer";
399399
CODE_SIGN_STYLE = Automatic;
400400
DEVELOPMENT_TEAM = R63EM248DP;
401-
FRAMEWORK_SEARCH_PATHS = (
402-
"$(inherited)",
403-
"$(PROJECT_DIR)/Pods/ACPCoreBeta",
404-
);
405401
INFOPLIST_FILE = "$(SRCROOT)/AdobeBranchExample/Info.plist";
406402
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
407403
LD_RUNPATH_SEARCH_PATHS = (
@@ -424,10 +420,6 @@
424420
CODE_SIGN_IDENTITY = "iPhone Developer";
425421
CODE_SIGN_STYLE = Automatic;
426422
DEVELOPMENT_TEAM = R63EM248DP;
427-
FRAMEWORK_SEARCH_PATHS = (
428-
"$(inherited)",
429-
"$(PROJECT_DIR)/Pods/ACPCoreBeta",
430-
);
431423
INFOPLIST_FILE = "$(SRCROOT)/AdobeBranchExample/Info.plist";
432424
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
433425
LD_RUNPATH_SEARCH_PATHS = (

Examples/AdobeBranchExample/AdobeBranchExample/AppDelegate.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
4545
}
4646
[ACPCore start:nil];
4747

48+
// Disable event sharing
49+
//[AdobeBranchExtension configureEventTypes:nil andEventSources:nil];
50+
4851
[AdobeBranchExtension initSessionWithLaunchOptions:launchOptions andRegisterDeepLinkHandler:^(NSDictionary * _Nullable params, NSError * _Nullable error) {
4952
if (!error && params && [params[@"+clicked_branch_link"] boolValue]) {
5053

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ Here's an example of tracking app state via Adobe Launch:
132132
@"currency": @"USD"
133133
}];
134134

135+
You can also customize which event types and sources are shared with Branch. Providing empty lists disables sharing.
136+
137+
[AdobeBranchExtension configureEventTypes:@[ @"com.adobe.eventType.generic.track" ] andEventSources:@[ @"com.adobe.eventSource.requestContent" ];
138+
135139
## License
136140

137141
AdobeBranchExtension is available under the MIT license. See the LICENSE file for more info.

0 commit comments

Comments
 (0)