Skip to content

Commit 699f047

Browse files
authored
Merge pull request #5 from BranchMetrics/staging
Merge updated binaries and version
2 parents 4e004d9 + ea74f1a commit 699f047

File tree

19 files changed

+382
-86
lines changed

19 files changed

+382
-86
lines changed

Branch.xcodeproj/project.pbxproj

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@
213213
4DF818C020B025DA00441881 /* BNCEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF818BE20B025DA00441881 /* BNCEncoder.h */; };
214214
4DF818C120B025DA00441881 /* BNCEncoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DF818BF20B025DA00441881 /* BNCEncoder.m */; };
215215
4DFB135A20CCFAE800AF3E47 /* BranchOpen.Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DFB135920CCFAE800AF3E47 /* BranchOpen.Test.m */; };
216+
5F7BD69D23341EB00067E5DA /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F7BD69C23341EB00067E5DA /* WebKit.framework */; };
217+
5F909B802334124D00A774D2 /* BNCUserAgentCollectorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F909B7F2334124D00A774D2 /* BNCUserAgentCollectorTests.m */; };
218+
5FA17909232702F10012B500 /* BNCUserAgentCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FA17907232702F00012B500 /* BNCUserAgentCollector.h */; };
219+
5FA1791723270F2B0012B500 /* BNCUserAgentCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FA17908232702F00012B500 /* BNCUserAgentCollector.m */; };
220+
5FA313A22327107B007BAA6A /* BNCUserAgentCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FA17908232702F00012B500 /* BNCUserAgentCollector.m */; };
216221
/* End PBXBuildFile section */
217222

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

328337
/* Begin PBXFrameworksBuildPhase section */
@@ -345,6 +354,7 @@
345354
isa = PBXFrameworksBuildPhase;
346355
buildActionMask = 2147483647;
347356
files = (
357+
5F7BD69D23341EB00067E5DA /* WebKit.framework in Frameworks */,
348358
4D0F1241216F2FD10008080A /* AdSupport.framework in Frameworks */,
349359
);
350360
runOnlyForDeploymentPostprocessing = 0;
@@ -389,6 +399,8 @@
389399
4D9C163D20ACBEF6002BF211 /* BNCApplication.m */,
390400
4D9C165C20ACD625002BF211 /* BNCDevice.h */,
391401
4D9C165D20ACD625002BF211 /* BNCDevice.m */,
402+
5FA17907232702F00012B500 /* BNCUserAgentCollector.h */,
403+
5FA17908232702F00012B500 /* BNCUserAgentCollector.m */,
392404
4DF818BE20B025DA00441881 /* BNCEncoder.h */,
393405
4DF818BF20B025DA00441881 /* BNCEncoder.m */,
394406
4D9C164620ACCD7C002BF211 /* BNCKeyChain.h */,
@@ -452,6 +464,7 @@
452464
4D54C08220A6560400C76496 /* BranchTests */ = {
453465
isa = PBXGroup;
454466
children = (
467+
5F909B7F2334124D00A774D2 /* BNCUserAgentCollectorTests.m */,
455468
4D9C165620ACD00E002BF211 /* BNCApplication.Test.m */,
456469
4D9C166220AD090F002BF211 /* BNCDevice.Test.m */,
457470
4DF818C220B031EB00441881 /* BNCEncoder.Test.m */,
@@ -498,6 +511,7 @@
498511
4DC2232220AA19A2005C57D0 /* Frameworks */ = {
499512
isa = PBXGroup;
500513
children = (
514+
5F7BD69C23341EB00067E5DA /* WebKit.framework */,
501515
4D0F124B216F398D0008080A /* AdSupport.framework */,
502516
4D0F1249216F39800008080A /* AdSupport.framework */,
503517
4D0F1240216F2FD10008080A /* AdSupport.framework */,
@@ -527,6 +541,7 @@
527541
4D170FA5216D1CC00083D6B6 /* Branch.h in Headers */,
528542
4D170FA6216D1CC00083D6B6 /* BNCNetworkService.h in Headers */,
529543
4D170FA7216D1CC00083D6B6 /* BNCWireFormat.h in Headers */,
544+
5FA17909232702F10012B500 /* BNCUserAgentCollector.h in Headers */,
530545
4D170FA8216D1CC00083D6B6 /* BranchCommerce.h in Headers */,
531546
4D170FA9216D1CC00083D6B6 /* BranchNetworkServiceProtocol.h in Headers */,
532547
4D170FAA216D1CC00083D6B6 /* BNCKeyChain.h in Headers */,
@@ -801,6 +816,7 @@
801816
buildActionMask = 2147483647;
802817
files = (
803818
4D159DDB20B62DD5005A9850 /* BNCKeyChain.Test.m in Sources */,
819+
5F909B802334124D00A774D2 /* BNCUserAgentCollectorTests.m in Sources */,
804820
4D159DD920B62DD5005A9850 /* BNCDevice.Test.m in Sources */,
805821
4D159DE920B62DD5005A9850 /* BranchUniversalObject.Test.m in Sources */,
806822
4D159DE620B62DD5005A9850 /* BranchError.Test.m in Sources */,
@@ -837,6 +853,7 @@
837853
isa = PBXSourcesBuildPhase;
838854
buildActionMask = 2147483647;
839855
files = (
856+
5FA1791723270F2B0012B500 /* BNCUserAgentCollector.m in Sources */,
840857
4D170F7B216D1CC00083D6B6 /* BranchUniversalObject.m in Sources */,
841858
4D170F7C216D1CC00083D6B6 /* UIViewController+Branch.m in Sources */,
842859
4D170F7D216D1CC00083D6B6 /* BranchCommerce.m in Sources */,
@@ -872,6 +889,7 @@
872889
isa = PBXSourcesBuildPhase;
873890
buildActionMask = 2147483647;
874891
files = (
892+
5FA313A22327107B007BAA6A /* BNCUserAgentCollector.m in Sources */,
875893
4DF8189B20ADDC5000441881 /* BranchUniversalObject.m in Sources */,
876894
4DF34EA0210BC04B00E5D20C /* UIViewController+Branch.m in Sources */,
877895
4DF818A620ADE1BB00441881 /* BranchCommerce.m in Sources */,
@@ -1163,9 +1181,9 @@
11631181
4D54C08A20A6560400C76496 /* Debug */ = {
11641182
isa = XCBuildConfiguration;
11651183
buildSettings = {
1166-
CODE_SIGN_IDENTITY = "";
1184+
CODE_SIGN_IDENTITY = "Mac Developer";
11671185
CODE_SIGN_STYLE = Automatic;
1168-
DEVELOPMENT_TEAM = R63EM248DP;
1186+
DEVELOPMENT_TEAM = "";
11691187
PRODUCT_BUNDLE_IDENTIFIER = io.branch.sdk.mac;
11701188
PROVISIONING_PROFILE_SPECIFIER = "";
11711189
};
@@ -1176,7 +1194,7 @@
11761194
buildSettings = {
11771195
CODE_SIGN_IDENTITY = "";
11781196
CODE_SIGN_STYLE = Automatic;
1179-
DEVELOPMENT_TEAM = R63EM248DP;
1197+
DEVELOPMENT_TEAM = "";
11801198
PRODUCT_BUNDLE_IDENTIFIER = io.branch.sdk.mac;
11811199
PROVISIONING_PROFILE_SPECIFIER = "";
11821200
};
@@ -1279,7 +1297,7 @@
12791297
buildSettings = {
12801298
CODE_SIGN_IDENTITY = "";
12811299
CODE_SIGN_STYLE = Automatic;
1282-
DEVELOPMENT_TEAM = R63EM248DP;
1300+
DEVELOPMENT_TEAM = "";
12831301
PRODUCT_BUNDLE_IDENTIFIER = io.branch.sdk.mac;
12841302
PROVISIONING_PROFILE_SPECIFIER = "";
12851303
};

Branch.xcodeproj/xcshareddata/xcschemes/Branch-macOS.xcscheme

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,9 @@
4040
buildConfiguration = "UnitTests"
4141
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4242
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43+
shouldUseLaunchSchemeArgsEnv = "YES"
4344
enableUBSanitizer = "YES"
44-
codeCoverageEnabled = "YES"
45-
shouldUseLaunchSchemeArgsEnv = "YES">
46-
<Testables>
47-
<TestableReference
48-
skipped = "NO">
49-
<BuildableReference
50-
BuildableIdentifier = "primary"
51-
BlueprintIdentifier = "4D159DCA20B62D7D005A9850"
52-
BuildableName = "BranchTests.xctest"
53-
BlueprintName = "BranchTests"
54-
ReferencedContainer = "container:Branch.xcodeproj">
55-
</BuildableReference>
56-
</TestableReference>
57-
</Testables>
45+
codeCoverageEnabled = "YES">
5846
<MacroExpansion>
5947
<BuildableReference
6048
BuildableIdentifier = "primary"
@@ -71,6 +59,18 @@
7159
isEnabled = "YES">
7260
</AdditionalOption>
7361
</AdditionalOptions>
62+
<Testables>
63+
<TestableReference
64+
skipped = "NO">
65+
<BuildableReference
66+
BuildableIdentifier = "primary"
67+
BlueprintIdentifier = "4D159DCA20B62D7D005A9850"
68+
BuildableName = "BranchTests.xctest"
69+
BlueprintName = "BranchTests"
70+
ReferencedContainer = "container:Branch.xcodeproj">
71+
</BuildableReference>
72+
</TestableReference>
73+
</Testables>
7474
</TestAction>
7575
<LaunchAction
7676
buildConfiguration = "Debug"
@@ -91,8 +91,6 @@
9191
ReferencedContainer = "container:Branch.xcodeproj">
9292
</BuildableReference>
9393
</MacroExpansion>
94-
<AdditionalOptions>
95-
</AdditionalOptions>
9694
</LaunchAction>
9795
<ProfileAction
9896
buildConfiguration = "Release"

Branch.xcodeproj/xcshareddata/xcschemes/Branch-tvOS.xcscheme

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,10 @@
4040
buildConfiguration = "UnitTests"
4141
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4242
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43+
shouldUseLaunchSchemeArgsEnv = "YES"
4344
enableThreadSanitizer = "YES"
4445
enableUBSanitizer = "YES"
45-
codeCoverageEnabled = "YES"
46-
shouldUseLaunchSchemeArgsEnv = "YES">
47-
<Testables>
48-
<TestableReference
49-
skipped = "NO">
50-
<BuildableReference
51-
BuildableIdentifier = "primary"
52-
BlueprintIdentifier = "4D159DCA20B62D7D005A9850"
53-
BuildableName = "BranchTests.xctest"
54-
BlueprintName = "BranchTests"
55-
ReferencedContainer = "container:Branch.xcodeproj">
56-
</BuildableReference>
57-
</TestableReference>
58-
</Testables>
46+
codeCoverageEnabled = "YES">
5947
<MacroExpansion>
6048
<BuildableReference
6149
BuildableIdentifier = "primary"
@@ -72,6 +60,18 @@
7260
isEnabled = "YES">
7361
</AdditionalOption>
7462
</AdditionalOptions>
63+
<Testables>
64+
<TestableReference
65+
skipped = "NO">
66+
<BuildableReference
67+
BuildableIdentifier = "primary"
68+
BlueprintIdentifier = "4D159DCA20B62D7D005A9850"
69+
BuildableName = "BranchTests.xctest"
70+
BlueprintName = "BranchTests"
71+
ReferencedContainer = "container:Branch.xcodeproj">
72+
</BuildableReference>
73+
</TestableReference>
74+
</Testables>
7575
</TestAction>
7676
<LaunchAction
7777
buildConfiguration = "Debug"
@@ -92,8 +92,6 @@
9292
ReferencedContainer = "container:Branch.xcodeproj">
9393
</BuildableReference>
9494
</MacroExpansion>
95-
<AdditionalOptions>
96-
</AdditionalOptions>
9795
</LaunchAction>
9896
<ProfileAction
9997
buildConfiguration = "Release"

Branch/BNCDevice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ NS_ASSUME_NONNULL_BEGIN
3737
@property (atomic, copy, readonly) NSString *language; //!< The iso2 language code (en, ml).
3838
@property (atomic, copy, readonly) NSString *localIPAddress; //!< The current local IPv4 address.
3939
@property (atomic, copy, readonly) NSArray<NSString*> *allLocalIPAddresses; //!< All local IP addresses.
40+
41+
@property (atomic, copy, readonly) NSString *userAgent;
42+
4043
@end
4144

4245
NS_ASSUME_NONNULL_END

Branch/BNCDevice.m

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#import "BNCDevice.h"
1212
#import "BNCLog.h"
1313
#import "BNCNetworkInformation.h"
14+
#if !TARGET_OS_TV
15+
#import "BNCUserAgentCollector.h"
16+
#endif
1417

1518
#import <sys/sysctl.h>
1619
#import <CommonCrypto/CommonCrypto.h>
@@ -175,26 +178,10 @@ + (NSString*) systemBuildVersion {
175178
}
176179

177180
+ (NSString*) networkAddress {
178-
NSMutableString* string = nil;
179181
BNCNetworkInformation*info = [BNCNetworkInformation local];
180-
NSData*data = info.address;
181-
if (!data || data.length != 6) return nil;
182-
183-
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
184-
CC_SHA1(data.bytes, (const unsigned int) data.length, digest);
185-
186-
// SHA1 is 160 bits = 20 bytes
187-
188-
string = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
189-
for (int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
190-
[string appendFormat:@"%02x", digest[i]];
191-
192-
// Truncate last four bytes to make UUID:
193-
194-
if (string.length < 32) return nil; // What?
195-
NSString*result = [NSString stringWithFormat:@"mac_%@", string];
196-
197-
return result;
182+
if (!info.displayAddress || info.displayAddress.length == 0) return nil;
183+
184+
return [info.displayAddress copy];
198185
}
199186

200187
#if TARGET_OS_OSX
@@ -261,6 +248,10 @@ + (instancetype) createCurrentDevice {
261248
device->_country = [self country];
262249
device->_language = [self language];
263250

251+
#if !TARGET_OS_TV
252+
device->_userAgent = [BNCUserAgentCollector instance].userAgent;
253+
#endif
254+
264255
return device;
265256
}
266257

@@ -297,11 +288,6 @@ - (NSString *)vendorID {
297288

298289
- (NSString*) hardwareID {
299290
NSString*s;
300-
s = [self netAddress];
301-
if (s) {
302-
_hardwareIDType = @"mac_id";
303-
return s;
304-
}
305291
s = [self advertisingID];
306292
if (s) {
307293
_hardwareIDType = @"idfa";
@@ -312,6 +298,11 @@ - (NSString*) hardwareID {
312298
_hardwareIDType = @"vendor_id";
313299
return s;
314300
}
301+
s = [self netAddress];
302+
if (s) {
303+
_hardwareIDType = @"mac_address";
304+
return s;
305+
}
315306
s = [[NSUUID UUID] UUIDString];
316307
_hardwareIDType = @"random";
317308
return s;
@@ -337,7 +328,7 @@ - (NSMutableDictionary*) v1dictionary {
337328
addString(hardwareIDType, hardware_id_type);
338329
addString(vendorID, idfv);
339330
addString(advertisingID, idfa);
340-
addString(netAddress, mac_id);
331+
addString(netAddress, mac_address);
341332
addString(country, country);
342333
addString(language, language);
343334
addString(brandName, brand);
@@ -348,6 +339,7 @@ - (NSMutableDictionary*) v1dictionary {
348339
addBoolean(deviceIsUnidentified, unidentified_device);
349340
addString(localIPAddress, local_ip);
350341
addString(systemName, os);
342+
addString(userAgent, user_agent);
351343

352344
if (!self.deviceIsUnidentified)
353345
dictionary[@"is_hardware_id_real"] = BNCWireFormatFromBool(YES);
@@ -365,7 +357,7 @@ - (NSMutableDictionary*) v2dictionary {
365357
addString(systemVersion, os_version);
366358
addString(vendorID, idfv);
367359
addString(advertisingID, idfa);
368-
addString(netAddress, mac_id);
360+
addString(netAddress, mac_address);
369361
addString(country, country);
370362
addString(language, language);
371363
addString(brandName, brand);
@@ -375,6 +367,7 @@ - (NSMutableDictionary*) v2dictionary {
375367
addDouble(screenSize.width, screen_width);
376368
addBoolean(deviceIsUnidentified, unidentified_device);
377369
addString(localIPAddress, local_ip);
370+
addString(userAgent, user_agent);
378371

379372
return dictionary;
380373
}

Branch/BNCUserAgentCollector.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// BNCUserAgentCollector.h
3+
// Branch
4+
//
5+
// Created by Ernest Cho on 8/29/19.
6+
// Copyright © 2019 Branch, Inc. All rights reserved.
7+
//
8+
9+
@import Foundation;
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface BNCUserAgentCollector : NSObject
14+
15+
+ (BNCUserAgentCollector *)instance;
16+
17+
@property (nonatomic, copy, readwrite) NSString *userAgent;
18+
19+
- (void)loadUserAgentWithCompletion:(void (^)(NSString * _Nullable userAgent))completion;
20+
21+
@end
22+
23+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)