Skip to content

Commit 153a896

Browse files
committed
Release 1.43.0
1 parent a189a66 commit 153a896

26 files changed

+877
-52
lines changed

Branch-SDK/BNCConfig.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
NSString * const BNC_API_BASE_URL = @"https://api2.branch.io";
1212
NSString * const BNC_API_VERSION = @"v1";
1313
NSString * const BNC_LINK_URL = @"https://bnc.lt";
14-
NSString * const BNC_SDK_VERSION = @"1.42.0";
14+
NSString * const BNC_SDK_VERSION = @"1.43.0";

Branch-SDK/BNCQRCodeCache.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// BNCQRCodeCache.h
3+
// Branch
4+
//
5+
// Created by Nipun Singh on 5/5/22.
6+
// Copyright © 2022 Branch, Inc. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface BNCQRCodeCache : NSObject
14+
15+
+ (BNCQRCodeCache *) sharedInstance;
16+
- (void)addQRCodeToCache:(NSData *)qrCodeData withParams:(NSMutableDictionary *)parameters;
17+
- (NSData *)checkQRCodeCache:(NSMutableDictionary *)parameters;
18+
19+
@end
20+
21+
NS_ASSUME_NONNULL_END

Branch-SDK/BNCQRCodeCache.m

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// BNCQRCodeCache.m
3+
// Branch
4+
//
5+
// Created by Nipun Singh on 5/5/22.
6+
// Copyright © 2022 Branch, Inc. All rights reserved.
7+
//
8+
9+
#import "BNCQRCodeCache.h"
10+
11+
@interface BNCQRCodeCache()
12+
@property (nonatomic, strong) NSMutableDictionary *cache;
13+
@end
14+
15+
@implementation BNCQRCodeCache
16+
17+
//Can only hold one QR code in cache. Just used to debounce.
18+
+ (BNCQRCodeCache *) sharedInstance {
19+
static BNCQRCodeCache *singleton;
20+
static dispatch_once_t onceToken;
21+
dispatch_once(&onceToken, ^{
22+
singleton = [BNCQRCodeCache new];
23+
});
24+
return singleton;
25+
}
26+
27+
- (instancetype)init {
28+
if ((self = [super init])) {
29+
self.cache = [[NSMutableDictionary alloc] init];
30+
}
31+
return self;
32+
}
33+
34+
- (void)addQRCodeToCache:(NSData *)qrCodeData withParams:(NSMutableDictionary *)parameters {
35+
@synchronized (self) {
36+
[self.cache removeAllObjects];
37+
NSMutableDictionary *tempParams = [parameters mutableCopy];
38+
[tempParams[@"data"] removeObjectForKey:@"$creation_timestamp"];
39+
self.cache[tempParams] = qrCodeData;
40+
}
41+
}
42+
43+
- (NSData *)checkQRCodeCache:(NSMutableDictionary *)parameters {
44+
NSData *qrCode;
45+
@synchronized (self) {
46+
NSMutableDictionary *tempParams = [parameters mutableCopy];
47+
[tempParams[@"data"] removeObjectForKey:@"$creation_timestamp"];
48+
qrCode = self.cache[tempParams];
49+
}
50+
return qrCode;
51+
}
52+
53+
@end

Branch-SDK/BNCSKAdNetwork.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
2020

2121
- (void)updateConversionValue:(NSInteger)conversionValue;
2222

23+
- (void)updatePostbackConversionValue:(NSInteger)conversionValue
24+
completionHandler:(void (^)(NSError *error))completion;
25+
2326
@end
2427

2528
NS_ASSUME_NONNULL_END

Branch-SDK/BNCSKAdNetwork.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ @interface BNCSKAdNetwork()
1616
@property (nonatomic, strong, readwrite) Class skAdNetworkClass;
1717
@property (nonatomic, assign, readwrite) SEL skAdNetworkRegisterAppForAdNetworkAttribution;
1818
@property (nonatomic, assign, readwrite) SEL skAdNetworkUpdateConversionValue;
19+
@property (nonatomic, assign, readwrite) SEL skAdNetworkUpdatePostbackConversionValue;
1920

2021
@end
2122

@@ -40,6 +41,7 @@ - (instancetype)init {
4041
self.skAdNetworkClass = NSClassFromString(@"SKAdNetwork");
4142
self.skAdNetworkRegisterAppForAdNetworkAttribution = NSSelectorFromString(@"registerAppForAdNetworkAttribution");
4243
self.skAdNetworkUpdateConversionValue = NSSelectorFromString(@"updateConversionValue:");
44+
self.skAdNetworkUpdatePostbackConversionValue = NSSelectorFromString(@"updatePostbackConversionValue:completionHandler:");
4345
}
4446
return self;
4547
}
@@ -77,4 +79,16 @@ - (void)updateConversionValue:(NSInteger)conversionValue {
7779
}
7880
}
7981

82+
- (void)updatePostbackConversionValue:(NSInteger)conversionValue
83+
completionHandler:(void (^)(NSError *error))completion {
84+
if (@available(iOS 15.4, *)) {
85+
if ([self shouldAttemptSKAdNetworkCallout]) {
86+
87+
// Equivalent call [SKAdNetwork updatePostbackConversionValue:completionHandler:];
88+
((id (*)(id, SEL, NSInteger,void (^)(NSError *error)))[self.skAdNetworkClass methodForSelector:self.skAdNetworkUpdatePostbackConversionValue])(self.skAdNetworkClass, self.skAdNetworkUpdatePostbackConversionValue, conversionValue, completion);
89+
}
90+
}
91+
92+
}
93+
8094
@end

Branch-SDK/Branch+Validator.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ - (void) showNextStep {
190190
"https://<yourapp>.app.link/NdJ6nFzRbK\n\n"
191191
"click on:\n"
192192
"https://<yourapp>.app.link/NdJ6nFzRbK?bnc_validate=true";
193-
NSLog(
194-
@"\n----------------------------------------------------------------------------"
195-
"\nBranch Integration Next Steps\n"
196-
"\n"
197-
"%@"
198-
"\n----------------------------------------------------------------------------", message);
193+
194+
NSLog(@"----------------------------------------------------------------------------");
195+
NSLog(@"Branch Integration Next Steps:");
196+
NSLog(@"%@", message);
197+
NSLog(@"----------------------------------------------------------------------------");
198+
199199
[self showAlertWithTitle:@"Next Step" message:message];
200200
}
201201

Branch-SDK/Branch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#import "UIViewController+Branch.h"
3535
#import "BranchScene.h"
3636
#import "BranchPluginSupport.h"
37+
#import "BranchQRCode.h"
3738

3839
#if !TARGET_OS_TV
3940
// tvOS does not support these features

Branch-SDK/BranchEvent.m

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,22 @@ - (void)processResponse:(BNCServerResponse*)response error:(NSError*)error {
8080
if (dictionary && [dictionary[BRANCH_RESPONSE_KEY_UPDATE_CONVERSION_VALUE] isKindOfClass:NSNumber.class]) {
8181
NSNumber *conversionValue = (NSNumber *)dictionary[BRANCH_RESPONSE_KEY_UPDATE_CONVERSION_VALUE];
8282
if (conversionValue) {
83-
[[BNCSKAdNetwork sharedInstance] updateConversionValue:conversionValue.integerValue];
83+
if (@available(iOS 15.4, *)) {
84+
[[BNCSKAdNetwork sharedInstance] updatePostbackConversionValue:conversionValue.intValue completionHandler: ^(NSError *error){
85+
if (self.completion) {
86+
self.completion(nil, error);
87+
}
88+
if (error) {
89+
BNCLogError([NSString stringWithFormat:@"Update conversion value failed with error - %@", [error description]]);
90+
} else {
91+
BNCLogDebug([NSString stringWithFormat:@"Update conversion value was successful. Conversion Value - %@", conversionValue]);
92+
}
93+
return;
94+
}];
95+
return;
96+
} else {
97+
[[BNCSKAdNetwork sharedInstance] updateConversionValue:conversionValue.integerValue];
98+
}
8499
}
85100
}
86101

@@ -270,7 +285,7 @@ - (BranchEventRequest *)buildRequestWithEventDictionary:(NSDictionary *)eventDic
270285
([self.class.standardEvents containsObject:self.eventName])
271286
? [NSString stringWithFormat:@"%@/%@", preferenceHelper.branchAPIURL, @"v2/event/standard"]
272287
: [NSString stringWithFormat:@"%@/%@", preferenceHelper.branchAPIURL, @"v2/event/custom"];
273-
288+
274289
BranchEventRequest *request =
275290
[[BranchEventRequest alloc]
276291
initWithServerURL:[NSURL URLWithString:serverURL]

Branch-SDK/BranchQRCode.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
//
2+
// BranchQRCode.h
3+
// Branch
4+
//
5+
// Created by Nipun Singh on 3/22/22.
6+
// Copyright © 2022 Branch, Inc. All rights reserved.
7+
//
8+
9+
#import "BranchUniversalObject.h"
10+
#import "BranchLinkProperties.h"
11+
12+
NS_ASSUME_NONNULL_BEGIN
13+
14+
typedef NS_ENUM(NSInteger, BranchQRCodeImageFormat){
15+
BranchQRCodeImageFormatPNG,
16+
BranchQRCodeImageFormatJPEG
17+
};
18+
19+
@interface BranchQRCode : NSObject
20+
21+
/// Primary color of the generated QR code itself.
22+
@property (nonatomic, strong, readwrite) UIColor *codeColor;
23+
/// Secondary color used as the QR Code background.
24+
@property (nonatomic, strong, readwrite) UIColor *backgroundColor;
25+
/// A URL of an image that will be added to the center of the QR code. Must be a PNG or JPEG.
26+
@property (nonatomic, copy, readwrite) NSString *centerLogo;
27+
/// Output size of QR Code image. Min 300px. Max 2000px.
28+
@property (nonatomic, copy, readwrite) NSNumber *width;
29+
/// The number of pixels for the QR code's border. Min 1px. Max 20px.
30+
@property (nonatomic, copy, readwrite) NSNumber *margin;
31+
/// Format of the returned QR code. Can be a JPEG or PNG.
32+
@property (nonatomic, assign, readwrite) BranchQRCodeImageFormat imageFormat;
33+
34+
/**
35+
Creates a Branch QR Code image. Returns the QR code as NSData.
36+
37+
@param buo The Branch Universal Object the will be shared.
38+
@param lp The link properties that the link will have.
39+
@param completion Completion handler containing the QR code image and error.
40+
41+
*/
42+
- (void)getQRCodeAsData:(nullable BranchUniversalObject *)buo
43+
linkProperties:(nullable BranchLinkProperties *)lp
44+
completion:(void(^)(NSData * _Nullable qrCode, NSError * _Nullable error))completion;
45+
46+
/**
47+
Creates a Branch QR Code image. Returns the QR code as a UIImage.
48+
49+
@param buo The Branch Universal Object the will be shared.
50+
@param lp The link properties that the link will have.
51+
@param completion Completion handler containing the QR code image and error.
52+
53+
*/
54+
- (void)getQRCodeAsImage:(nullable BranchUniversalObject *)buo
55+
linkProperties:(nullable BranchLinkProperties *)lp
56+
completion:(void(^)(UIImage * _Nullable qrCode, NSError * _Nullable error))completion;
57+
58+
59+
/**
60+
Creates a Branch QR Code image and displays it in a share sheet.
61+
62+
@param buo The Branch Universal Object the will be shared.
63+
@param lp The link properties that the link will have.
64+
@param completion Completion handler containing any potential error.
65+
66+
*/
67+
#if !TARGET_OS_TV
68+
- (void)showShareSheetWithQRCodeFromViewController:(nullable UIViewController *)viewController
69+
anchor:(nullable id)anchorViewOrButtonItem
70+
universalObject:(nullable BranchUniversalObject *)buo
71+
linkProperties:(nullable BranchLinkProperties *)lp
72+
completion:(void(^)(NSError * _Nullable error))completion;
73+
#endif
74+
75+
@end
76+
77+
NS_ASSUME_NONNULL_END
78+

0 commit comments

Comments
 (0)