Skip to content

Commit 214b051

Browse files
committed
add currency to BUO
1 parent 2bbe71f commit 214b051

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

Branch-SDK/Branch-SDK/Branch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ extern NSString * const BRANCH_INIT_KEY_CLICKED_BRANCH_LINK;
106106
// BUO Constants
107107
extern NSString * const BNCCanonicalIdList;
108108
extern NSString * const BNCPurchaseAmount;
109+
extern NSString * const BNCPurchaseCurrency;
109110
extern NSString * const BNCCanonicalIdList;
110111
extern NSString * const BNCPurchaseAmount;
111112
extern NSString * const BNCRegisterViewEvent;

Branch-SDK/Branch-SDK/Branch.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
NSString * const BNCCanonicalIdList = @"$canonical_identifier_list";
6060
NSString * const BNCPurchaseAmount = @"$amount";
61+
NSString * const BNCPurchaseCurrency = @"$currency";
6162
NSString * const BNCRegisterViewEvent = @"View";
6263
NSString * const BNCAddToWishlistEvent = @"Add to Wishlist";
6364
NSString * const BNCAddToCartEvent = @"Add to Cart";

Branch-SDK/Branch-SDK/BranchUniversalObject.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
@class BranchLinkProperties;
1313

14-
typedef void (^_Nullable callback) ();
1514
typedef void (^shareCompletion) (NSString *_Nonnull activityType, BOOL completed);
1615

1716
typedef NS_ENUM(NSInteger, ContentIndexMode) {
@@ -34,6 +33,8 @@ typedef NS_ENUM(NSInteger, ContentIndexMode) {
3433
@property (nonatomic, strong) NSDate *expirationDate;
3534
@property (nonatomic, strong) NSString *spotlightIdentifier;
3635
@property (nonatomic, assign) CGFloat price;
36+
@property (nonatomic, strong) NSString *currency;
37+
3738

3839
- (instancetype)initWithCanonicalIdentifier:(NSString *)canonicalIdentifier;
3940
- (instancetype)initWithTitle:(NSString *)title;

Branch-SDK/Branch-SDK/BranchUniversalObject.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ + (BranchUniversalObject *)getBranchUniversalObjectFromDictionary:(NSDictionary
323323
if (dictionary[BNCPurchaseAmount]) {
324324
universalObject.price = [dictionary[BNCPurchaseAmount] floatValue];
325325
}
326+
if (dictionary[BNCPurchaseCurrency]) {
327+
universalObject.currency = dictionary[BNCPurchaseCurrency];
328+
}
326329

327330
return universalObject;
328331
}
@@ -349,9 +352,13 @@ - (NSDictionary *)getParamsForServerRequest {
349352
[self safeSetValue:self.keywords forKey:BRANCH_LINK_DATA_KEY_KEYWORDS onDict:temp];
350353
[self safeSetValue:@(1000 * [self.expirationDate timeIntervalSince1970]) forKey:BRANCH_LINK_DATA_KEY_CONTENT_EXPIRATION_DATE onDict:temp];
351354
[self safeSetValue:self.type forKey:BRANCH_LINK_DATA_KEY_CONTENT_TYPE onDict:temp];
355+
[self safeSetValue:self.currency forKey:BNCPurchaseCurrency onDict:temp];
352356
if (self.price) {
357+
// have to add if statement because safeSetValue only accepts objects so even if self.price is not set
358+
// a valid NSNumber object will be created and the request will have amount:0 in all cases.
353359
[self safeSetValue:[NSNumber numberWithFloat:self.price] forKey:BNCPurchaseAmount onDict:temp];
354360
}
361+
355362
[temp addEntriesFromDictionary:[self.metadata copy]];
356363
return [temp copy];
357364
}

Branch-TestBed/Branch-TestBed/ViewController.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ - (void)viewDidLoad {
5555
_branchUniversalObject.title = contentTitle;
5656
_branchUniversalObject.contentDescription = contentDescription;
5757
_branchUniversalObject.imageUrl = imageUrl;
58+
_branchUniversalObject.price = 1000;
59+
_branchUniversalObject.currency = @"$";
5860
[_branchUniversalObject addMetadataKey:@"deeplink_text" value:[NSString stringWithFormat:
5961
@"This text was embedded as data in a Branch link with the following characteristics:\n\n canonicalUrl: %@\n title: %@\n contentDescription: %@\n imageUrl: %@\n", canonicalUrl, contentTitle, contentDescription, imageUrl]];
6062
[self refreshRewardPoints];

0 commit comments

Comments
 (0)