Skip to content

Commit 2c68666

Browse files
author
Edward Smith
committed
Merge branch 'QA' of ssh://github.com/BranchMetrics/ios-branch-deep-linking into better-release-scripts-AIS-172
2 parents b80a58f + ff9fd2f commit 2c68666

File tree

7 files changed

+166
-45
lines changed

7 files changed

+166
-45
lines changed

Branch-SDK/Branch-SDK/BNCCommerceEvent.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,45 @@
1111
#import "BNCServerRequest.h"
1212

1313

14+
#pragma mark BNCProductCategory
15+
16+
typedef NSString*const BNCProductCategory;
17+
18+
extern BNCProductCategory BNCProductCategoryAnimalSupplies;
19+
extern BNCProductCategory BNCProductCategoryApparel;
20+
extern BNCProductCategory BNCProductCategoryArtsEntertainment;
21+
extern BNCProductCategory BNCProductCategoryBabyToddler;
22+
extern BNCProductCategory BNCProductCategoryBusinessIndustrial;
23+
extern BNCProductCategory BNCProductCategoryCamerasOptics;
24+
extern BNCProductCategory BNCProductCategoryElectronics;
25+
extern BNCProductCategory BNCProductCategoryFoodBeverageTobacco;
26+
extern BNCProductCategory BNCProductCategoryFurniture;
27+
extern BNCProductCategory BNCProductCategoryHardware;
28+
extern BNCProductCategory BNCProductCategoryHealthBeauty;
29+
extern BNCProductCategory BNCProductCategoryHomeGarden;
30+
extern BNCProductCategory BNCProductCategoryLuggageBags;
31+
extern BNCProductCategory BNCProductCategoryMature;
32+
extern BNCProductCategory BNCProductCategoryMedia;
33+
extern BNCProductCategory BNCProductCategoryOfficeSupplies;
34+
extern BNCProductCategory BNCProductCategoryReligious;
35+
extern BNCProductCategory BNCProductCategorySoftware;
36+
extern BNCProductCategory BNCProductCategorySportingGoods;
37+
extern BNCProductCategory BNCProductCategoryToysGames;
38+
extern BNCProductCategory BNCProductCategoryVehiclesParts;
39+
40+
#pragma mark - BNCProduct
41+
1442
@interface BNCProduct : NSObject
1543
@property (nonatomic, strong) NSString *sku;
1644
@property (nonatomic, strong) NSString *name;
1745
@property (nonatomic, strong) NSDecimalNumber *price;
1846
@property (nonatomic, strong) NSNumber *quantity;
1947
@property (nonatomic, strong) NSString *brand;
20-
@property (nonatomic, strong) NSString *category;
48+
@property (nonatomic, strong) BNCProductCategory category;
2149
@property (nonatomic, strong) NSString *variant;
2250
@end
2351

52+
#pragma mark - BNCCommerceEvent
2453

2554
@interface BNCCommerceEvent : NSObject
2655
@property (nonatomic, strong) NSDecimalNumber *revenue;

Branch-SDK/Branch-SDK/BNCCommerceEvent.m

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,32 @@
1111
#import "BranchConstants.h"
1212

1313

14+
#pragma mark BNCProductCategory
15+
16+
BNCProductCategory BNCProductCategoryAnimalSupplies = @"Animals & Pet Supplies";
17+
BNCProductCategory BNCProductCategoryApparel = @"Apparel & Accessories";
18+
BNCProductCategory BNCProductCategoryArtsEntertainment = @"Arts & Entertainment";
19+
BNCProductCategory BNCProductCategoryBabyToddler = @"Baby & Toddler";
20+
BNCProductCategory BNCProductCategoryBusinessIndustrial = @"Business & Industrial";
21+
BNCProductCategory BNCProductCategoryCamerasOptics = @"Cameras & Optics";
22+
BNCProductCategory BNCProductCategoryElectronics = @"Electronics";
23+
BNCProductCategory BNCProductCategoryFoodBeverageTobacco = @"Food, Beverages & Tobacco";
24+
BNCProductCategory BNCProductCategoryFurniture = @"Furniture";
25+
BNCProductCategory BNCProductCategoryHardware = @"Hardware";
26+
BNCProductCategory BNCProductCategoryHealthBeauty = @"Health & Beauty";
27+
BNCProductCategory BNCProductCategoryHomeGarden = @"Home & Garden";
28+
BNCProductCategory BNCProductCategoryLuggageBags = @"Luggage & Bags";
29+
BNCProductCategory BNCProductCategoryMature = @"Mature";
30+
BNCProductCategory BNCProductCategoryMedia = @"Media";
31+
BNCProductCategory BNCProductCategoryOfficeSupplies = @"Office Supplies";
32+
BNCProductCategory BNCProductCategoryReligious = @"Religious & Ceremonial";
33+
BNCProductCategory BNCProductCategorySoftware = @"Software";
34+
BNCProductCategory BNCProductCategorySportingGoods = @"Sporting Goods";
35+
BNCProductCategory BNCProductCategoryToysGames = @"Toys & Games";
36+
BNCProductCategory BNCProductCategoryVehiclesParts = @"Vehicles & Parts";
37+
38+
#pragma mark - BNCProduct
39+
1440
@implementation BNCProduct
1541

1642
- (NSMutableDictionary*) dictionary {
@@ -32,8 +58,21 @@ - (NSMutableDictionary*) dictionary {
3258
return dictionary;
3359
}
3460

61+
- (NSString*) description {
62+
return [NSString stringWithFormat:
63+
@"Name: %@ Sku: %@ Price: %@ Quantity: %@ Brand: %@ Category: %@ Variant: %@",
64+
self.name,
65+
self.sku,
66+
self.price,
67+
self.quantity,
68+
self.brand,
69+
self.category,
70+
self.variant];
71+
}
72+
3573
@end
3674

75+
#pragma mark - BNCCommerceEvent
3776

3877
@implementation BNCCommerceEvent : NSObject
3978

@@ -63,6 +102,19 @@ - (NSDictionary*) dictionary {
63102
return dictionary;
64103
}
65104

105+
- (NSString*) description {
106+
return [NSString stringWithFormat:
107+
@"Revenue: %@ Currency: %@ TxID: %@ Shipping: %@ Tax: %@ Coupon: %@ Affl: %@ Products: %lu",
108+
self.revenue,
109+
self.currency,
110+
self.transactionID,
111+
self.shipping,
112+
self.tax,
113+
self.coupon,
114+
self.affiliation,
115+
(unsigned long) self.products.count];
116+
}
117+
66118
@end
67119

68120

@@ -130,7 +182,7 @@ - (void)processResponse:(BNCServerResponse*)response
130182
}
131183

132184

133-
#pragma mark - NSCoding
185+
#pragma mark BranchCommerceEventRequest NSCoding
134186

135187

136188
- (instancetype)initWithCoder:(NSCoder *)decoder {

Branch-SDK/Branch-SDK/BNCStrongMatchHelper.m

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,25 @@ - (UIWindow*) keyWindow {
248248
return nil;
249249
}
250250

251+
/**
252+
Find the top view controller that is not of type UINavigationController or UITabBarController
253+
*/
254+
- (UIViewController *)topViewController:(UIViewController *)baseViewController {
255+
if ([baseViewController isKindOfClass:[UINavigationController class]]) {
256+
return [self topViewController: ((UINavigationController *)baseViewController).visibleViewController];
257+
}
258+
259+
if ([baseViewController isKindOfClass:[UITabBarController class]]) {
260+
return [self topViewController: ((UITabBarController *)baseViewController).selectedViewController];
261+
}
262+
263+
if ([baseViewController presentedViewController] != nil) {
264+
return [self topViewController: [baseViewController presentedViewController]];
265+
}
266+
267+
return baseViewController;
268+
}
269+
251270
- (BOOL) willLoadViewControllerWithURL:(NSURL*)matchURL {
252271
if (self.primaryWindow) return NO;
253272

@@ -291,11 +310,13 @@ - (BOOL) willLoadViewControllerWithURL:(NSURL*)matchURL {
291310
self.matchView.alpha = 1.0;
292311
[self.matchView addSubview:self.matchViewController.view];
293312

294-
[self.primaryWindow.rootViewController addChildViewController:self.matchViewController];
295-
UIView *parentView = self.primaryWindow.rootViewController.view ?: self.primaryWindow;
313+
UIViewController *rootViewController = [self topViewController:self.primaryWindow.rootViewController];
314+
315+
[rootViewController addChildViewController:self.matchViewController];
316+
UIView *parentView = rootViewController.view ?: self.primaryWindow;
296317
[parentView insertSubview:self.matchView atIndex:0];
297318

298-
[self.matchViewController didMoveToParentViewController:self.primaryWindow.rootViewController];
319+
[self.matchViewController didMoveToParentViewController:rootViewController];
299320

300321
return YES;
301322
}

Branch-SDK/Branch-SDK/Branch.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,9 @@ - (NSDictionary *)getFirstReferringParams {
797797
NSDictionary *origInstallParams = [BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.installParams];
798798

799799
if (self.deepLinkDebugParams) {
800-
NSMutableDictionary* debugInstallParams = [[BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.sessionParams] mutableCopy];
800+
NSMutableDictionary* debugInstallParams =
801+
[[BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.sessionParams]
802+
mutableCopy];
801803
[debugInstallParams addEntriesFromDictionary:self.deepLinkDebugParams];
802804
return debugInstallParams;
803805
}

Branch-SDK/Branch-SDK/Requests/BranchUserCompletedActionRequest.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,17 @@ - (id)initWithAction:(NSString *)action state:(NSDictionary *)state withBranchVi
3636
return self;
3737
}
3838

39-
- (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key callback:(BNCServerCallback)callback {
39+
- (void)makeRequest:(BNCServerInterface *)serverInterface
40+
key:(NSString *)key
41+
callback:(BNCServerCallback)callback {
42+
43+
// Emit a warning if the action is collides with the Branch commerce 'purchase' event.
44+
if (self.action && [self.action isEqualToString:@"purchase"]) {
45+
NSLog(@"[Branch] Warning: You are sending a purchase event with our non-dedicated purchase "
46+
"method. Please use the sendCommerceEvent:metadata:withCompletion: method.");
47+
}
48+
4049
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
41-
4250
BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper preferenceHelper];
4351
params[BRANCH_REQUEST_KEY_ACTION] = self.action;
4452
params[BRANCH_REQUEST_KEY_DEVICE_FINGERPRINT_ID] = preferenceHelper.deviceFingerprintID;

Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -479,56 +479,56 @@
479479
670016BB1946309100A9E103 /* Branch-SDK */ = {
480480
isa = PBXGroup;
481481
children = (
482-
7D0C97081D875177004E14B1 /* BranchContentDiscovery */,
483482
E2B947491D15D73900F2270D /* BNCCallbacks.h */,
484-
7D4DAC221C8FA908008E37DB /* BranchViewHandler.m */,
485-
7D4DAC231C8FA908008E37DB /* BranchView.m */,
486-
7D4DAC241C8FA908008E37DB /* BranchViewHandler.h */,
487-
7D4DAC201C8FA8C0008E37DB /* BranchView.h */,
488-
4659B3471B0FD4430019767C /* BranchRequests */,
489-
670016BD1946309100A9E103 /* Branch.h */,
490-
670016BE1946309100A9E103 /* Branch.m */,
491-
4665AF221B28935700184037 /* BranchConstants.h */,
492-
4665AF251B28B9BB00184037 /* BranchConstants.m */,
483+
7E6ACAF919E324120066913E /* BNCConfig.h */,
484+
4D3FA94A1DFF31EB00E2B6A9 /* BNCConfig.m */,
485+
466D5A0F1B5991E3009DB845 /* BNCContentDiscoveryManager.h */,
486+
466D5A101B5991E3009DB845 /* BNCContentDiscoveryManager.m */,
487+
7D5882301CA1BEEA00FF6358 /* BNCDeviceInfo.h */,
488+
7D5882391CA1DF2700FF6358 /* BNCDeviceInfo.m */,
489+
464EA3991ACB38EC000E4094 /* BNCEncodingUtils.h */,
490+
464EA39A1ACB38EC000E4094 /* BNCEncodingUtils.m */,
491+
7E38829E1A37E22A004BDABE /* BNCError.h */,
492+
7E38829F1A37E22A004BDABE /* BNCError.m */,
493+
E2133B711D0125EF00763049 /* BNCFabricAnswers.h */,
494+
E2133B741D01477200763049 /* BNCFabricAnswers.m */,
495+
7E30BCF51A72FE7900AC7402 /* BNCLinkCache.h */,
496+
7E30BCF61A72FE7900AC7402 /* BNCLinkCache.m */,
497+
7E30BCF21A71EEEE00AC7402 /* BNCLinkData.h */,
498+
7E30BCF31A71EEEE00AC7402 /* BNCLinkData.m */,
493499
670016C11946309100A9E103 /* BNCPreferenceHelper.h */,
494500
670016C21946309100A9E103 /* BNCPreferenceHelper.m */,
495501
670016C31946309100A9E103 /* BNCServerInterface.h */,
496502
670016C41946309100A9E103 /* BNCServerInterface.m */,
497-
670016C71946309100A9E103 /* BNCSystemObserver.h */,
498-
670016C81946309100A9E103 /* BNCSystemObserver.m */,
499503
7E6ACAF619E324090066913E /* BNCServerRequestQueue.h */,
500504
7E6ACAF719E324090066913E /* BNCServerRequestQueue.m */,
501-
7E6ACAF919E324120066913E /* BNCConfig.h */,
502-
4D3FA94A1DFF31EB00E2B6A9 /* BNCConfig.m */,
503-
7E38829E1A37E22A004BDABE /* BNCError.h */,
504-
7E38829F1A37E22A004BDABE /* BNCError.m */,
505505
7EAA790819E90B9F008D4A83 /* BNCServerResponse.h */,
506506
7EAA790919E90B9F008D4A83 /* BNCServerResponse.m */,
507-
7E30BCF21A71EEEE00AC7402 /* BNCLinkData.h */,
508-
7E30BCF31A71EEEE00AC7402 /* BNCLinkData.m */,
509-
7E30BCF51A72FE7900AC7402 /* BNCLinkCache.h */,
510-
7E30BCF61A72FE7900AC7402 /* BNCLinkCache.m */,
511-
D258D2C41A794D64004A1C90 /* BranchActivityItemProvider.h */,
512-
D258D2C51A794D64004A1C90 /* BranchActivityItemProvider.m */,
513-
464EA3991ACB38EC000E4094 /* BNCEncodingUtils.h */,
514-
464EA39A1ACB38EC000E4094 /* BNCEncodingUtils.m */,
515-
46DBB42F1B335A9B00642FC8 /* BranchDeepLinkingController.h */,
516-
466D5A0F1B5991E3009DB845 /* BNCContentDiscoveryManager.h */,
517-
466D5A101B5991E3009DB845 /* BNCContentDiscoveryManager.m */,
518507
67486B8B1B93B48A0044D872 /* BNCStrongMatchHelper.h */,
519508
67486B8C1B93B48A0044D872 /* BNCStrongMatchHelper.m */,
509+
670016C71946309100A9E103 /* BNCSystemObserver.h */,
510+
670016C81946309100A9E103 /* BNCSystemObserver.m */,
511+
4D8999EA1DC108FF00F7EE0A /* BNCXcode7Support.h */,
512+
4D8999EB1DC108FF00F7EE0A /* BNCXcode7Support.m */,
513+
670016BD1946309100A9E103 /* Branch.h */,
514+
670016BE1946309100A9E103 /* Branch.m */,
515+
D258D2C41A794D64004A1C90 /* BranchActivityItemProvider.h */,
516+
D258D2C51A794D64004A1C90 /* BranchActivityItemProvider.m */,
517+
4665AF221B28935700184037 /* BranchConstants.h */,
518+
4665AF251B28B9BB00184037 /* BranchConstants.m */,
519+
7D0C97081D875177004E14B1 /* BranchContentDiscovery */,
520520
54391A131BA249FA0061CB0F /* BranchCSSearchableItemAttributeSet.h */,
521521
54391A141BA249FA0061CB0F /* BranchCSSearchableItemAttributeSet.m */,
522-
54FF1F8B1BD1D4AE0004CE2E /* BranchUniversalObject.h */,
523-
54FF1F8C1BD1D4AE0004CE2E /* BranchUniversalObject.m */,
522+
46DBB42F1B335A9B00642FC8 /* BranchDeepLinkingController.h */,
524523
54FF1F8F1BD1DC320004CE2E /* BranchLinkProperties.h */,
525524
54FF1F901BD1DC320004CE2E /* BranchLinkProperties.m */,
526-
7D5882301CA1BEEA00FF6358 /* BNCDeviceInfo.h */,
527-
7D5882391CA1DF2700FF6358 /* BNCDeviceInfo.m */,
528-
E2133B711D0125EF00763049 /* BNCFabricAnswers.h */,
529-
E2133B741D01477200763049 /* BNCFabricAnswers.m */,
530-
4D8999EA1DC108FF00F7EE0A /* BNCXcode7Support.h */,
531-
4D8999EB1DC108FF00F7EE0A /* BNCXcode7Support.m */,
525+
4659B3471B0FD4430019767C /* BranchRequests */,
526+
54FF1F8B1BD1D4AE0004CE2E /* BranchUniversalObject.h */,
527+
54FF1F8C1BD1D4AE0004CE2E /* BranchUniversalObject.m */,
528+
7D4DAC201C8FA8C0008E37DB /* BranchView.h */,
529+
7D4DAC231C8FA908008E37DB /* BranchView.m */,
530+
7D4DAC241C8FA908008E37DB /* BranchViewHandler.h */,
531+
7D4DAC221C8FA908008E37DB /* BranchViewHandler.m */,
532532
);
533533
name = "Branch-SDK";
534534
path = "../Branch-SDK/Branch-SDK";

Branch-TestBed/Branch-TestBed/ViewController.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ - (IBAction) sendCommerceEvent:(id)sender {
205205
product.name = @"Acme brand 1 ton weight";
206206
product.quantity = @(1.0);
207207
product.brand = @"Acme";
208-
product.category = @"Widgets";
208+
product.category = BNCProductCategoryMedia;
209209
product.variant = @"Lite Weight";
210210

211211
BNCCommerceEvent *commerceEvent = [BNCCommerceEvent new];
@@ -223,7 +223,16 @@ - (IBAction) sendCommerceEvent:(id)sender {
223223
metadata:@{ @"Meta": @"Never meta dog I didn't like." }
224224
withCompletion:
225225
^ (NSDictionary *response, NSError *error) {
226-
NSLog(@"Completion called. Error: %@\n%@", error, response);
226+
NSString *message =
227+
[NSString stringWithFormat:@"Commerce completion called.\nError: %@\n%@", error, response];
228+
NSLog(@"%@", message);
229+
[[[UIAlertView alloc]
230+
initWithTitle:@"Commerce Event"
231+
message:message
232+
delegate:nil
233+
cancelButtonTitle:@"OK"
234+
otherButtonTitles:nil]
235+
show];
227236
}];
228237
}
229238

0 commit comments

Comments
 (0)