Skip to content

Commit

Permalink
Merge pull request #5 from BranchMetrics/staging
Browse files Browse the repository at this point in the history
Merge updated binaries and version
  • Loading branch information
echo-branch authored Oct 15, 2019
2 parents 4e004d9 + ea74f1a commit 699f047
Show file tree
Hide file tree
Showing 19 changed files with 382 additions and 86 deletions.
26 changes: 22 additions & 4 deletions Branch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@
4DF818C020B025DA00441881 /* BNCEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF818BE20B025DA00441881 /* BNCEncoder.h */; };
4DF818C120B025DA00441881 /* BNCEncoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DF818BF20B025DA00441881 /* BNCEncoder.m */; };
4DFB135A20CCFAE800AF3E47 /* BranchOpen.Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DFB135920CCFAE800AF3E47 /* BranchOpen.Test.m */; };
5F7BD69D23341EB00067E5DA /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F7BD69C23341EB00067E5DA /* WebKit.framework */; };
5F909B802334124D00A774D2 /* BNCUserAgentCollectorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F909B7F2334124D00A774D2 /* BNCUserAgentCollectorTests.m */; };
5FA17909232702F10012B500 /* BNCUserAgentCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FA17907232702F00012B500 /* BNCUserAgentCollector.h */; };
5FA1791723270F2B0012B500 /* BNCUserAgentCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FA17908232702F00012B500 /* BNCUserAgentCollector.m */; };
5FA313A22327107B007BAA6A /* BNCUserAgentCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FA17908232702F00012B500 /* BNCUserAgentCollector.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -323,6 +328,10 @@
4DF818BF20B025DA00441881 /* BNCEncoder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCEncoder.m; sourceTree = "<group>"; };
4DF818C220B031EB00441881 /* BNCEncoder.Test.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCEncoder.Test.m; sourceTree = "<group>"; };
4DFB135920CCFAE800AF3E47 /* BranchOpen.Test.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BranchOpen.Test.m; sourceTree = "<group>"; };
5F7BD69C23341EB00067E5DA /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
5F909B7F2334124D00A774D2 /* BNCUserAgentCollectorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCUserAgentCollectorTests.m; sourceTree = "<group>"; };
5FA17907232702F00012B500 /* BNCUserAgentCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCUserAgentCollector.h; sourceTree = "<group>"; };
5FA17908232702F00012B500 /* BNCUserAgentCollector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCUserAgentCollector.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -345,6 +354,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
5F7BD69D23341EB00067E5DA /* WebKit.framework in Frameworks */,
4D0F1241216F2FD10008080A /* AdSupport.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -389,6 +399,8 @@
4D9C163D20ACBEF6002BF211 /* BNCApplication.m */,
4D9C165C20ACD625002BF211 /* BNCDevice.h */,
4D9C165D20ACD625002BF211 /* BNCDevice.m */,
5FA17907232702F00012B500 /* BNCUserAgentCollector.h */,
5FA17908232702F00012B500 /* BNCUserAgentCollector.m */,
4DF818BE20B025DA00441881 /* BNCEncoder.h */,
4DF818BF20B025DA00441881 /* BNCEncoder.m */,
4D9C164620ACCD7C002BF211 /* BNCKeyChain.h */,
Expand Down Expand Up @@ -452,6 +464,7 @@
4D54C08220A6560400C76496 /* BranchTests */ = {
isa = PBXGroup;
children = (
5F909B7F2334124D00A774D2 /* BNCUserAgentCollectorTests.m */,
4D9C165620ACD00E002BF211 /* BNCApplication.Test.m */,
4D9C166220AD090F002BF211 /* BNCDevice.Test.m */,
4DF818C220B031EB00441881 /* BNCEncoder.Test.m */,
Expand Down Expand Up @@ -498,6 +511,7 @@
4DC2232220AA19A2005C57D0 /* Frameworks */ = {
isa = PBXGroup;
children = (
5F7BD69C23341EB00067E5DA /* WebKit.framework */,
4D0F124B216F398D0008080A /* AdSupport.framework */,
4D0F1249216F39800008080A /* AdSupport.framework */,
4D0F1240216F2FD10008080A /* AdSupport.framework */,
Expand Down Expand Up @@ -527,6 +541,7 @@
4D170FA5216D1CC00083D6B6 /* Branch.h in Headers */,
4D170FA6216D1CC00083D6B6 /* BNCNetworkService.h in Headers */,
4D170FA7216D1CC00083D6B6 /* BNCWireFormat.h in Headers */,
5FA17909232702F10012B500 /* BNCUserAgentCollector.h in Headers */,
4D170FA8216D1CC00083D6B6 /* BranchCommerce.h in Headers */,
4D170FA9216D1CC00083D6B6 /* BranchNetworkServiceProtocol.h in Headers */,
4D170FAA216D1CC00083D6B6 /* BNCKeyChain.h in Headers */,
Expand Down Expand Up @@ -801,6 +816,7 @@
buildActionMask = 2147483647;
files = (
4D159DDB20B62DD5005A9850 /* BNCKeyChain.Test.m in Sources */,
5F909B802334124D00A774D2 /* BNCUserAgentCollectorTests.m in Sources */,
4D159DD920B62DD5005A9850 /* BNCDevice.Test.m in Sources */,
4D159DE920B62DD5005A9850 /* BranchUniversalObject.Test.m in Sources */,
4D159DE620B62DD5005A9850 /* BranchError.Test.m in Sources */,
Expand Down Expand Up @@ -837,6 +853,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5FA1791723270F2B0012B500 /* BNCUserAgentCollector.m in Sources */,
4D170F7B216D1CC00083D6B6 /* BranchUniversalObject.m in Sources */,
4D170F7C216D1CC00083D6B6 /* UIViewController+Branch.m in Sources */,
4D170F7D216D1CC00083D6B6 /* BranchCommerce.m in Sources */,
Expand Down Expand Up @@ -872,6 +889,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5FA313A22327107B007BAA6A /* BNCUserAgentCollector.m in Sources */,
4DF8189B20ADDC5000441881 /* BranchUniversalObject.m in Sources */,
4DF34EA0210BC04B00E5D20C /* UIViewController+Branch.m in Sources */,
4DF818A620ADE1BB00441881 /* BranchCommerce.m in Sources */,
Expand Down Expand Up @@ -1163,9 +1181,9 @@
4D54C08A20A6560400C76496 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = R63EM248DP;
DEVELOPMENT_TEAM = "";
PRODUCT_BUNDLE_IDENTIFIER = io.branch.sdk.mac;
PROVISIONING_PROFILE_SPECIFIER = "";
};
Expand All @@ -1176,7 +1194,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = R63EM248DP;
DEVELOPMENT_TEAM = "";
PRODUCT_BUNDLE_IDENTIFIER = io.branch.sdk.mac;
PROVISIONING_PROFILE_SPECIFIER = "";
};
Expand Down Expand Up @@ -1279,7 +1297,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = R63EM248DP;
DEVELOPMENT_TEAM = "";
PRODUCT_BUNDLE_IDENTIFIER = io.branch.sdk.mac;
PROVISIONING_PROFILE_SPECIFIER = "";
};
Expand Down
30 changes: 14 additions & 16 deletions Branch.xcodeproj/xcshareddata/xcschemes/Branch-macOS.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,9 @@
buildConfiguration = "UnitTests"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
enableUBSanitizer = "YES"
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4D159DCA20B62D7D005A9850"
BuildableName = "BranchTests.xctest"
BlueprintName = "BranchTests"
ReferencedContainer = "container:Branch.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -71,6 +59,18 @@
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4D159DCA20B62D7D005A9850"
BuildableName = "BranchTests.xctest"
BlueprintName = "BranchTests"
ReferencedContainer = "container:Branch.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -91,8 +91,6 @@
ReferencedContainer = "container:Branch.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
30 changes: 14 additions & 16 deletions Branch.xcodeproj/xcshareddata/xcschemes/Branch-tvOS.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,10 @@
buildConfiguration = "UnitTests"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
enableThreadSanitizer = "YES"
enableUBSanitizer = "YES"
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4D159DCA20B62D7D005A9850"
BuildableName = "BranchTests.xctest"
BlueprintName = "BranchTests"
ReferencedContainer = "container:Branch.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -72,6 +60,18 @@
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4D159DCA20B62D7D005A9850"
BuildableName = "BranchTests.xctest"
BlueprintName = "BranchTests"
ReferencedContainer = "container:Branch.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -92,8 +92,6 @@
ReferencedContainer = "container:Branch.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
3 changes: 3 additions & 0 deletions Branch/BNCDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (atomic, copy, readonly) NSString *language; //!< The iso2 language code (en, ml).
@property (atomic, copy, readonly) NSString *localIPAddress; //!< The current local IPv4 address.
@property (atomic, copy, readonly) NSArray<NSString*> *allLocalIPAddresses; //!< All local IP addresses.

@property (atomic, copy, readonly) NSString *userAgent;

@end

NS_ASSUME_NONNULL_END
45 changes: 19 additions & 26 deletions Branch/BNCDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#import "BNCDevice.h"
#import "BNCLog.h"
#import "BNCNetworkInformation.h"
#if !TARGET_OS_TV
#import "BNCUserAgentCollector.h"
#endif

#import <sys/sysctl.h>
#import <CommonCrypto/CommonCrypto.h>
Expand Down Expand Up @@ -175,26 +178,10 @@ + (NSString*) systemBuildVersion {
}

+ (NSString*) networkAddress {
NSMutableString* string = nil;
BNCNetworkInformation*info = [BNCNetworkInformation local];
NSData*data = info.address;
if (!data || data.length != 6) return nil;

uint8_t digest[CC_SHA1_DIGEST_LENGTH];
CC_SHA1(data.bytes, (const unsigned int) data.length, digest);

// SHA1 is 160 bits = 20 bytes

string = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
for (int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
[string appendFormat:@"%02x", digest[i]];

// Truncate last four bytes to make UUID:

if (string.length < 32) return nil; // What?
NSString*result = [NSString stringWithFormat:@"mac_%@", string];

return result;
if (!info.displayAddress || info.displayAddress.length == 0) return nil;

return [info.displayAddress copy];
}

#if TARGET_OS_OSX
Expand Down Expand Up @@ -261,6 +248,10 @@ + (instancetype) createCurrentDevice {
device->_country = [self country];
device->_language = [self language];

#if !TARGET_OS_TV
device->_userAgent = [BNCUserAgentCollector instance].userAgent;
#endif

return device;
}

Expand Down Expand Up @@ -297,11 +288,6 @@ - (NSString *)vendorID {

- (NSString*) hardwareID {
NSString*s;
s = [self netAddress];
if (s) {
_hardwareIDType = @"mac_id";
return s;
}
s = [self advertisingID];
if (s) {
_hardwareIDType = @"idfa";
Expand All @@ -312,6 +298,11 @@ - (NSString*) hardwareID {
_hardwareIDType = @"vendor_id";
return s;
}
s = [self netAddress];
if (s) {
_hardwareIDType = @"mac_address";
return s;
}
s = [[NSUUID UUID] UUIDString];
_hardwareIDType = @"random";
return s;
Expand All @@ -337,7 +328,7 @@ - (NSMutableDictionary*) v1dictionary {
addString(hardwareIDType, hardware_id_type);
addString(vendorID, idfv);
addString(advertisingID, idfa);
addString(netAddress, mac_id);
addString(netAddress, mac_address);
addString(country, country);
addString(language, language);
addString(brandName, brand);
Expand All @@ -348,6 +339,7 @@ - (NSMutableDictionary*) v1dictionary {
addBoolean(deviceIsUnidentified, unidentified_device);
addString(localIPAddress, local_ip);
addString(systemName, os);
addString(userAgent, user_agent);

if (!self.deviceIsUnidentified)
dictionary[@"is_hardware_id_real"] = BNCWireFormatFromBool(YES);
Expand All @@ -365,7 +357,7 @@ - (NSMutableDictionary*) v2dictionary {
addString(systemVersion, os_version);
addString(vendorID, idfv);
addString(advertisingID, idfa);
addString(netAddress, mac_id);
addString(netAddress, mac_address);
addString(country, country);
addString(language, language);
addString(brandName, brand);
Expand All @@ -375,6 +367,7 @@ - (NSMutableDictionary*) v2dictionary {
addDouble(screenSize.width, screen_width);
addBoolean(deviceIsUnidentified, unidentified_device);
addString(localIPAddress, local_ip);
addString(userAgent, user_agent);

return dictionary;
}
Expand Down
23 changes: 23 additions & 0 deletions Branch/BNCUserAgentCollector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// BNCUserAgentCollector.h
// Branch
//
// Created by Ernest Cho on 8/29/19.
// Copyright © 2019 Branch, Inc. All rights reserved.
//

@import Foundation;

NS_ASSUME_NONNULL_BEGIN

@interface BNCUserAgentCollector : NSObject

+ (BNCUserAgentCollector *)instance;

@property (nonatomic, copy, readwrite) NSString *userAgent;

- (void)loadUserAgentWithCompletion:(void (^)(NSString * _Nullable userAgent))completion;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit 699f047

Please sign in to comment.