-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ea8069
commit d84d1d5
Showing
340 changed files
with
41,996 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
highlight-color: "#5691AD" | ||
highlight-dark-color: "#6EBADF" | ||
darker-color: "#205E72" | ||
darker-dark-color: "#0A3D49" | ||
background-color: "#e3e3e3" | ||
alt-link-color: "#7273B6" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1160" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "Branch" | ||
BuildableName = "Branch" | ||
BlueprintName = "Branch" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "Branch" | ||
BuildableName = "Branch" | ||
BlueprintName = "Branch" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// BNCAppleAdClient.h | ||
// Branch | ||
// | ||
// Created by Ernest Cho on 11/7/19. | ||
// Copyright © 2019 Branch, Inc. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
// protocol for easier mocking of ADClient behavior in tests | ||
@protocol BNCAppleAdClientProtocol <NSObject> | ||
|
||
@required | ||
- (void)requestAttributionDetailsWithBlock:(void (^)(NSDictionary<NSString *,NSObject *> *attributionDetails, NSError *error))completionHandler; | ||
|
||
@end | ||
|
||
@interface BNCAppleAdClient : NSObject <BNCAppleAdClientProtocol> | ||
|
||
- (void)requestAttributionDetailsWithBlock:(void (^)(NSDictionary<NSString *,NSObject *> *attributionDetails, NSError *error))completionHandler; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// | ||
// BNCAppleAdClient.m | ||
// Branch | ||
// | ||
// Created by Ernest Cho on 11/7/19. | ||
// Copyright © 2019 Branch, Inc. All rights reserved. | ||
// | ||
|
||
#import "BNCAppleAdClient.h" | ||
#import "NSError+Branch.h" | ||
|
||
@interface BNCAppleAdClient() | ||
|
||
@property (nonatomic, strong, readwrite) Class adClientClass; | ||
@property (nonatomic, assign, readwrite) SEL adClientSharedClient; | ||
@property (nonatomic, assign, readwrite) SEL adClientRequestAttribution; | ||
|
||
@property (nonatomic, strong, readwrite) id adClient; | ||
|
||
@end | ||
|
||
// ADClient facade that uses reflection to detect and make it available | ||
@implementation BNCAppleAdClient | ||
|
||
- (instancetype)init { | ||
self = [super init]; | ||
if (self) { | ||
self.adClientClass = NSClassFromString(@"ADClient"); | ||
self.adClientSharedClient = NSSelectorFromString(@"sharedClient"); | ||
self.adClientRequestAttribution = NSSelectorFromString(@"requestAttributionDetailsWithBlock:"); | ||
|
||
self.adClient = [self loadAdClient]; | ||
} | ||
return self; | ||
} | ||
|
||
- (id)loadAdClient { | ||
if ([self isAdClientAvailable]) { | ||
return ((id (*)(id, SEL))[self.adClientClass methodForSelector:self.adClientSharedClient])(self.adClientClass, self.adClientSharedClient); | ||
} | ||
return nil; | ||
} | ||
|
||
- (BOOL)isAdClientAvailable { | ||
BOOL ADClientIsAvailable = self.adClientClass && | ||
[self.adClientClass instancesRespondToSelector:self.adClientRequestAttribution] && | ||
[self.adClientClass methodForSelector:self.adClientSharedClient]; | ||
|
||
if (ADClientIsAvailable) { | ||
return YES; | ||
} | ||
return NO; | ||
} | ||
|
||
- (void)requestAttributionDetailsWithBlock:(void (^)(NSDictionary<NSString *,NSObject *> *attributionDetails, NSError *error))completionHandler { | ||
if (self.adClient) { | ||
((void (*)(id, SEL, void (^ __nullable)(NSDictionary *__nullable attrDetails, NSError * __nullable error))) | ||
[self.adClient methodForSelector:self.adClientRequestAttribution]) | ||
(self.adClient, self.adClientRequestAttribution, completionHandler); | ||
} else { | ||
if (completionHandler) { | ||
completionHandler(nil, [NSError branchErrorWithCode:BNCGeneralError localizedMessage:@"ADClient is not available. Requires iAD.framework and iOS 10+"]); | ||
} | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// BNCAppleReceipt.h | ||
// Branch | ||
// | ||
// Created by Ernest Cho on 7/11/19. | ||
// Copyright © 2019 Branch, Inc. All rights reserved. | ||
// | ||
|
||
#if __has_feature(modules) | ||
@import Foundation; | ||
#else | ||
#import <Foundation/Foundation.h> | ||
#endif | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface BNCAppleReceipt : NSObject | ||
|
||
+ (BNCAppleReceipt *)sharedInstance; | ||
|
||
// this is only available on builds from Apple | ||
- (nullable NSString *)installReceipt; | ||
- (BOOL)isTestFlight; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// BNCAppleReceipt.m | ||
// Branch | ||
// | ||
// Created by Ernest Cho on 7/11/19. | ||
// Copyright © 2019 Branch, Inc. All rights reserved. | ||
// | ||
|
||
#import "BNCAppleReceipt.h" | ||
|
||
@interface BNCAppleReceipt() | ||
|
||
/* | ||
Simulator - no receipt, isSandbox = NO | ||
Testflight or developer side load - no receipt, isSandbox = YES | ||
App Store installed - receipt, isSandbox = NO | ||
*/ | ||
@property (nonatomic, copy, readwrite) NSString *receipt; | ||
@property (nonatomic, assign, readwrite) BOOL isSandboxReceipt; | ||
|
||
@end | ||
|
||
@implementation BNCAppleReceipt | ||
|
||
+ (BNCAppleReceipt *)sharedInstance { | ||
static BNCAppleReceipt *singleton; | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
singleton = [BNCAppleReceipt new]; | ||
}); | ||
return singleton; | ||
} | ||
|
||
- (instancetype)init { | ||
self = [super init]; | ||
if (self) { | ||
self.receipt = nil; | ||
self.isSandboxReceipt = NO; | ||
|
||
[self readReceipt]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)readReceipt { | ||
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL]; | ||
if (receiptURL) { | ||
self.isSandboxReceipt = [receiptURL.lastPathComponent isEqualToString:@"sandboxReceipt"]; | ||
|
||
NSData *receiptData = [NSData dataWithContentsOfURL:receiptURL]; | ||
if (receiptData) { | ||
self.receipt = [receiptData base64EncodedStringWithOptions:0]; | ||
} | ||
} | ||
} | ||
|
||
- (nullable NSString *)installReceipt { | ||
return self.receipt; | ||
} | ||
|
||
- (BOOL)isTestFlight { | ||
// sandbox receipts are from testflight or side loaded development devices | ||
return self.isSandboxReceipt; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// BNCAppleSearchAds.h | ||
// Branch | ||
// | ||
// Created by Ernest Cho on 10/22/19. | ||
// Copyright © 2019 Branch, Inc. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "BNCPreferenceHelper.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface BNCAppleSearchAds : NSObject | ||
|
||
@property (nonatomic, assign, readwrite) BOOL enableAppleSearchAdsCheck; | ||
@property (nonatomic, assign, readwrite) BOOL ignoreAppleTestData; | ||
|
||
+ (BNCAppleSearchAds *)sharedInstance; | ||
|
||
// Default delay and retry configuration. ~p90 | ||
// typically less than 1s delay, up to 3.5s delay on first app start | ||
- (void)useDefaultAppleSearchAdsConfig; | ||
|
||
// Apple suggests a longer delay, however this is detrimental to app launch times | ||
// typically less than 3s delay, up to 14s delay on first app start | ||
- (void)useLongWaitAppleSearchAdsConfig; | ||
|
||
// Checks Apple Search Ads and updates preferences | ||
// This method blocks the thread, it should only be called on a background thread. | ||
- (void)checkAppleSearchAdsSaveTo:(BNCPreferenceHelper *)preferenceHelper installDate:(NSDate *)installDate completion:(void (^_Nullable)(void))completion; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.