Skip to content

Commit d84d1d5

Browse files
[release] 0.35.0
1 parent 7ea8069 commit d84d1d5

File tree

340 files changed

+41996
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

340 files changed

+41996
-0
lines changed

.cocoadocs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
highlight-color: "#5691AD"
2+
highlight-dark-color: "#6EBADF"
3+
darker-color: "#205E72"
4+
darker-dark-color: "#0A3D49"
5+
background-color: "#e3e3e3"
6+
alt-link-color: "#7273B6"

.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1160"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "Branch"
18+
BuildableName = "Branch"
19+
BlueprintName = "Branch"
20+
ReferencedContainer = "container:">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
</LaunchAction>
44+
<ProfileAction
45+
buildConfiguration = "Release"
46+
shouldUseLaunchSchemeArgsEnv = "YES"
47+
savedToolIdentifier = ""
48+
useCustomWorkingDirectory = "NO"
49+
debugDocumentVersioning = "YES">
50+
<MacroExpansion>
51+
<BuildableReference
52+
BuildableIdentifier = "primary"
53+
BlueprintIdentifier = "Branch"
54+
BuildableName = "Branch"
55+
BlueprintName = "Branch"
56+
ReferencedContainer = "container:">
57+
</BuildableReference>
58+
</MacroExpansion>
59+
</ProfileAction>
60+
<AnalyzeAction
61+
buildConfiguration = "Debug">
62+
</AnalyzeAction>
63+
<ArchiveAction
64+
buildConfiguration = "Release"
65+
revealArchiveInOrganizer = "YES">
66+
</ArchiveAction>
67+
</Scheme>

Branch-SDK/BNCAppleAdClient.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// BNCAppleAdClient.h
3+
// Branch
4+
//
5+
// Created by Ernest Cho on 11/7/19.
6+
// Copyright © 2019 Branch, Inc. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
// protocol for easier mocking of ADClient behavior in tests
14+
@protocol BNCAppleAdClientProtocol <NSObject>
15+
16+
@required
17+
- (void)requestAttributionDetailsWithBlock:(void (^)(NSDictionary<NSString *,NSObject *> *attributionDetails, NSError *error))completionHandler;
18+
19+
@end
20+
21+
@interface BNCAppleAdClient : NSObject <BNCAppleAdClientProtocol>
22+
23+
- (void)requestAttributionDetailsWithBlock:(void (^)(NSDictionary<NSString *,NSObject *> *attributionDetails, NSError *error))completionHandler;
24+
25+
@end
26+
27+
NS_ASSUME_NONNULL_END

Branch-SDK/BNCAppleAdClient.m

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//
2+
// BNCAppleAdClient.m
3+
// Branch
4+
//
5+
// Created by Ernest Cho on 11/7/19.
6+
// Copyright © 2019 Branch, Inc. All rights reserved.
7+
//
8+
9+
#import "BNCAppleAdClient.h"
10+
#import "NSError+Branch.h"
11+
12+
@interface BNCAppleAdClient()
13+
14+
@property (nonatomic, strong, readwrite) Class adClientClass;
15+
@property (nonatomic, assign, readwrite) SEL adClientSharedClient;
16+
@property (nonatomic, assign, readwrite) SEL adClientRequestAttribution;
17+
18+
@property (nonatomic, strong, readwrite) id adClient;
19+
20+
@end
21+
22+
// ADClient facade that uses reflection to detect and make it available
23+
@implementation BNCAppleAdClient
24+
25+
- (instancetype)init {
26+
self = [super init];
27+
if (self) {
28+
self.adClientClass = NSClassFromString(@"ADClient");
29+
self.adClientSharedClient = NSSelectorFromString(@"sharedClient");
30+
self.adClientRequestAttribution = NSSelectorFromString(@"requestAttributionDetailsWithBlock:");
31+
32+
self.adClient = [self loadAdClient];
33+
}
34+
return self;
35+
}
36+
37+
- (id)loadAdClient {
38+
if ([self isAdClientAvailable]) {
39+
return ((id (*)(id, SEL))[self.adClientClass methodForSelector:self.adClientSharedClient])(self.adClientClass, self.adClientSharedClient);
40+
}
41+
return nil;
42+
}
43+
44+
- (BOOL)isAdClientAvailable {
45+
BOOL ADClientIsAvailable = self.adClientClass &&
46+
[self.adClientClass instancesRespondToSelector:self.adClientRequestAttribution] &&
47+
[self.adClientClass methodForSelector:self.adClientSharedClient];
48+
49+
if (ADClientIsAvailable) {
50+
return YES;
51+
}
52+
return NO;
53+
}
54+
55+
- (void)requestAttributionDetailsWithBlock:(void (^)(NSDictionary<NSString *,NSObject *> *attributionDetails, NSError *error))completionHandler {
56+
if (self.adClient) {
57+
((void (*)(id, SEL, void (^ __nullable)(NSDictionary *__nullable attrDetails, NSError * __nullable error)))
58+
[self.adClient methodForSelector:self.adClientRequestAttribution])
59+
(self.adClient, self.adClientRequestAttribution, completionHandler);
60+
} else {
61+
if (completionHandler) {
62+
completionHandler(nil, [NSError branchErrorWithCode:BNCGeneralError localizedMessage:@"ADClient is not available. Requires iAD.framework and iOS 10+"]);
63+
}
64+
}
65+
}
66+
67+
@end

Branch-SDK/BNCAppleReceipt.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// BNCAppleReceipt.h
3+
// Branch
4+
//
5+
// Created by Ernest Cho on 7/11/19.
6+
// Copyright © 2019 Branch, Inc. All rights reserved.
7+
//
8+
9+
#if __has_feature(modules)
10+
@import Foundation;
11+
#else
12+
#import <Foundation/Foundation.h>
13+
#endif
14+
15+
NS_ASSUME_NONNULL_BEGIN
16+
17+
@interface BNCAppleReceipt : NSObject
18+
19+
+ (BNCAppleReceipt *)sharedInstance;
20+
21+
// this is only available on builds from Apple
22+
- (nullable NSString *)installReceipt;
23+
- (BOOL)isTestFlight;
24+
25+
@end
26+
27+
NS_ASSUME_NONNULL_END

Branch-SDK/BNCAppleReceipt.m

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//
2+
// BNCAppleReceipt.m
3+
// Branch
4+
//
5+
// Created by Ernest Cho on 7/11/19.
6+
// Copyright © 2019 Branch, Inc. All rights reserved.
7+
//
8+
9+
#import "BNCAppleReceipt.h"
10+
11+
@interface BNCAppleReceipt()
12+
13+
/*
14+
Simulator - no receipt, isSandbox = NO
15+
Testflight or developer side load - no receipt, isSandbox = YES
16+
App Store installed - receipt, isSandbox = NO
17+
*/
18+
@property (nonatomic, copy, readwrite) NSString *receipt;
19+
@property (nonatomic, assign, readwrite) BOOL isSandboxReceipt;
20+
21+
@end
22+
23+
@implementation BNCAppleReceipt
24+
25+
+ (BNCAppleReceipt *)sharedInstance {
26+
static BNCAppleReceipt *singleton;
27+
static dispatch_once_t onceToken;
28+
dispatch_once(&onceToken, ^{
29+
singleton = [BNCAppleReceipt new];
30+
});
31+
return singleton;
32+
}
33+
34+
- (instancetype)init {
35+
self = [super init];
36+
if (self) {
37+
self.receipt = nil;
38+
self.isSandboxReceipt = NO;
39+
40+
[self readReceipt];
41+
}
42+
return self;
43+
}
44+
45+
- (void)readReceipt {
46+
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
47+
if (receiptURL) {
48+
self.isSandboxReceipt = [receiptURL.lastPathComponent isEqualToString:@"sandboxReceipt"];
49+
50+
NSData *receiptData = [NSData dataWithContentsOfURL:receiptURL];
51+
if (receiptData) {
52+
self.receipt = [receiptData base64EncodedStringWithOptions:0];
53+
}
54+
}
55+
}
56+
57+
- (nullable NSString *)installReceipt {
58+
return self.receipt;
59+
}
60+
61+
- (BOOL)isTestFlight {
62+
// sandbox receipts are from testflight or side loaded development devices
63+
return self.isSandboxReceipt;
64+
}
65+
66+
@end

Branch-SDK/BNCAppleSearchAds.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// BNCAppleSearchAds.h
3+
// Branch
4+
//
5+
// Created by Ernest Cho on 10/22/19.
6+
// Copyright © 2019 Branch, Inc. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "BNCPreferenceHelper.h"
11+
12+
NS_ASSUME_NONNULL_BEGIN
13+
14+
@interface BNCAppleSearchAds : NSObject
15+
16+
@property (nonatomic, assign, readwrite) BOOL enableAppleSearchAdsCheck;
17+
@property (nonatomic, assign, readwrite) BOOL ignoreAppleTestData;
18+
19+
+ (BNCAppleSearchAds *)sharedInstance;
20+
21+
// Default delay and retry configuration. ~p90
22+
// typically less than 1s delay, up to 3.5s delay on first app start
23+
- (void)useDefaultAppleSearchAdsConfig;
24+
25+
// Apple suggests a longer delay, however this is detrimental to app launch times
26+
// typically less than 3s delay, up to 14s delay on first app start
27+
- (void)useLongWaitAppleSearchAdsConfig;
28+
29+
// Checks Apple Search Ads and updates preferences
30+
// This method blocks the thread, it should only be called on a background thread.
31+
- (void)checkAppleSearchAdsSaveTo:(BNCPreferenceHelper *)preferenceHelper installDate:(NSDate *)installDate completion:(void (^_Nullable)(void))completion;
32+
33+
@end
34+
35+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)