Skip to content

Commit

Permalink
Merge pull request #13 from BranchMetrics/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
echo-branch authored Apr 12, 2019
2 parents 7e1e0df + 4676181 commit a8f1655
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 16 deletions.
2 changes: 1 addition & 1 deletion AdobeBranchExtension.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "AdobeBranchExtension"
s.version = "1.0.1"
s.version = "1.1.0"
s.summary = "The Branch extension for Adobe Cloud Platform on iOS."

s.description = <<-DESC
Expand Down
2 changes: 2 additions & 0 deletions AdobeBranchExtension/Classes/AdobeBranchExtensionClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ FOUNDATION_EXPORT NSString*const ABEBranchEventSource;

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

+ (void)configureEventTypes:(nullable NSArray<NSString *> *)eventTypes andEventSources:(nullable NSArray<NSString *> *)eventSources;

- (void)handleEvent:(ACPExtensionEvent*)event;

@end
Expand Down
30 changes: 23 additions & 7 deletions AdobeBranchExtension/Classes/AdobeBranchExtensionClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
//

#import "AdobeBranchExtension.h"
#import "AdobeBranchExtensionConfig.h"
#import <Branch/Branch.h>

#pragma mark Constants

NSString*const ABEBranchExtensionVersion = @"1.0.1";
NSString*const ABEBranchExtensionVersion = @"1.1.0";

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

+ (void)configureEventTypes:(nullable NSArray<NSString *> *)eventTypes andEventSources:(nullable NSArray<NSString *> *)eventSources {
if (eventTypes) {
[AdobeBranchExtensionConfig instance].eventTypes = eventTypes;
} else {
[AdobeBranchExtensionConfig instance].eventTypes = @[];
}

if (eventSources) {
[AdobeBranchExtensionConfig instance].eventSources = eventSources;
} else {
[AdobeBranchExtensionConfig instance].eventSources = @[];
}
}

- (instancetype)init {
self = [super init];
if (!self) return self;

BNCLogSetDisplayLevel(BNCLogLevelError);

NSError *error = nil;
if ([self.api registerWildcardListener:AdobeBranchExtensionListener.class error:&error])
if ([self.api registerWildcardListener:AdobeBranchExtensionListener.class error:&error]) {
BNCLogDebug(@"BranchExtensionRuleListener was registered.");
else
} else {
BNCLogError(@"Can't register AdobeBranchExtensionRuleListener: %@.", error);
}
return self;
}

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

if ([event.eventType isEqualToString:@"com.adobe.eventType.generic.track"] &&
[event.eventSource isEqualToString:@"com.adobe.eventSource.requestContent"]) {
if ([[AdobeBranchExtensionConfig instance].eventTypes containsObject:event.eventType] &&
[[AdobeBranchExtensionConfig instance].eventSources containsObject:event.eventSource]) {
[self trackEvent:event];
return;
}
Expand Down Expand Up @@ -126,7 +142,7 @@ - (void)handleEvent:(ACPExtensionEvent*)event {
return dictionary;
}

+ (BranchEvent *)branchEventFromAdbobeEventName:(NSString *)eventName
+ (BranchEvent *)branchEventFromAdobeEventName:(NSString *)eventName
dictionary:(NSDictionary *)dictionary {

if (eventName.length == 0) return nil;
Expand Down Expand Up @@ -186,7 +202,7 @@ - (void) trackEvent:(ACPExtensionEvent*)event {
if (!eventName.length) eventName = eventData[@"state"];
if (!eventName.length) return;
NSDictionary *content = [eventData objectForKey:@"contextdata"];
BranchEvent *branchEvent = [self.class branchEventFromAdbobeEventName:eventName dictionary:content];
BranchEvent *branchEvent = [self.class branchEventFromAdobeEventName:eventName dictionary:content];
[branchEvent logEvent];
}

Expand Down
20 changes: 20 additions & 0 deletions AdobeBranchExtension/Classes/AdobeBranchExtensionConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// AdobeBranchExtensionConfig.h
// Pods
//
// Created by Ernest Cho on 4/11/19.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface AdobeBranchExtensionConfig : NSObject
@property (nonatomic, strong, readwrite) NSArray<NSString *> *eventTypes;
@property (nonatomic, strong, readwrite) NSArray<NSString *> *eventSources;

+ (AdobeBranchExtensionConfig *)instance;

@end

NS_ASSUME_NONNULL_END
31 changes: 31 additions & 0 deletions AdobeBranchExtension/Classes/AdobeBranchExtensionConfig.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// AdobeBranchExtensionConfig.m
// Pods
//
// Created by Ernest Cho on 4/11/19.
//

#import "AdobeBranchExtensionConfig.h"

@implementation AdobeBranchExtensionConfig

+ (AdobeBranchExtensionConfig *)instance {
static AdobeBranchExtensionConfig *config;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
config = [AdobeBranchExtensionConfig new];
});
return config;
}

- (instancetype)init {
self = [super init];
if (self) {
// default event type and source to track, client can override
self.eventTypes = @[ @"com.adobe.eventType.generic.track" ];
self.eventSources = @[ @"com.adobe.eventSource.requestContent" ];
}
return self;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,6 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = R63EM248DP;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Pods/ACPCoreBeta",
);
INFOPLIST_FILE = "$(SRCROOT)/AdobeBranchExample/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -424,10 +420,6 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = R63EM248DP;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Pods/ACPCoreBeta",
);
INFOPLIST_FILE = "$(SRCROOT)/AdobeBranchExample/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
3 changes: 3 additions & 0 deletions Examples/AdobeBranchExample/AdobeBranchExample/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}
[ACPCore start:nil];

// Disable event sharing
//[AdobeBranchExtension configureEventTypes:nil andEventSources:nil];

[AdobeBranchExtension initSessionWithLaunchOptions:launchOptions andRegisterDeepLinkHandler:^(NSDictionary * _Nullable params, NSError * _Nullable error) {
if (!error && params && [params[@"+clicked_branch_link"] boolValue]) {

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ Here's an example of tracking app state via Adobe Launch:
@"currency": @"USD"
}];

You can also customize which event types and sources are shared with Branch. Providing empty lists disables sharing.

[AdobeBranchExtension configureEventTypes:@[ @"com.adobe.eventType.generic.track" ] andEventSources:@[ @"com.adobe.eventSource.requestContent" ];

## License

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

0 comments on commit a8f1655

Please sign in to comment.