Skip to content

Commit 9abd4a7

Browse files
author
Edward Smith
committed
Add-Keys-AIS-109-AIS-106
1 parent 4e6b8e0 commit 9abd4a7

File tree

6 files changed

+98
-36
lines changed

6 files changed

+98
-36
lines changed

Branch-SDK/Branch-SDK/BNCDeviceInfo.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@
2828
@property (nonatomic, strong) NSNumber *screenHeight;
2929
@property (nonatomic) BOOL isAdTrackingEnabled;
3030

31+
@property (nonatomic, strong) NSString* country; // iso2 Country name (us, in,etc).
32+
@property (nonatomic, strong) NSString* language; // iso2 language code (en, ml).
33+
@property (nonatomic, strong) NSString* browserUserAgent; // Simple user agent string.
34+
3135

3236
//----------Methods----------------//
3337
+ (BNCDeviceInfo *)getInstance;
3438

35-
@end
39+
@end

Branch-SDK/Branch-SDK/BNCDeviceInfo.m

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#import <Foundation/Foundation.h>
10+
#import <UIKit/UIKit.h>
1011
#import "BNCDeviceInfo.h"
1112
#import "BNCPreferenceHelper.h"
1213
#import "BNCSystemObserver.h"
@@ -27,26 +28,62 @@ + (BNCDeviceInfo *)getInstance {
2728
}
2829

2930
- (id)init {
30-
if (self = [super init]) {
31-
BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper preferenceHelper];
32-
BOOL isRealHardwareId;
33-
NSString *hardwareIdType;
34-
NSString *hardwareId = [BNCSystemObserver getUniqueHardwareId:&isRealHardwareId isDebug:preferenceHelper.isDebug andType:&hardwareIdType];
35-
if (hardwareId) {
36-
self.hardwareId = hardwareId;
37-
self.isRealHardwareId = isRealHardwareId;
38-
self.hardwareIdType = hardwareIdType;
31+
self = [super init];
32+
if (!self) return self;
33+
34+
BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper preferenceHelper];
35+
BOOL isRealHardwareId;
36+
NSString *hardwareIdType;
37+
NSString *hardwareId =
38+
[BNCSystemObserver getUniqueHardwareId:&isRealHardwareId
39+
isDebug:preferenceHelper.isDebug
40+
andType:&hardwareIdType];
41+
if (hardwareId) {
42+
self.hardwareId = hardwareId;
43+
self.isRealHardwareId = isRealHardwareId;
44+
self.hardwareIdType = hardwareIdType;
45+
}
46+
47+
self.vendorId = [BNCSystemObserver getVendorId];
48+
self.brandName = [BNCSystemObserver getBrand];
49+
self.modelName = [BNCSystemObserver getModel];
50+
self.osName = [BNCSystemObserver getOS];
51+
self.osVersion = [BNCSystemObserver getOSVersion];
52+
self.screenWidth = [BNCSystemObserver getScreenWidth];
53+
self.screenHeight = [BNCSystemObserver getScreenHeight];
54+
self.isAdTrackingEnabled = [BNCSystemObserver adTrackingSafe];
55+
56+
// Get the locale info --
57+
CGFloat systemVersion = [UIDevice currentDevice].systemVersion.floatValue;
58+
if (systemVersion < 9.0) {
59+
60+
self.language = [[NSLocale preferredLanguages] firstObject];
61+
NSString *rawLocale = [NSLocale currentLocale].localeIdentifier;
62+
NSRange range = [rawLocale rangeOfString:@"_"];
63+
if (range.location != NSNotFound) {
64+
range = NSMakeRange(range.location+1, rawLocale.length-range.location-1);
65+
self.country = [rawLocale substringWithRange:range];
3966
}
40-
41-
self.vendorId = [BNCSystemObserver getVendorId];
42-
self.brandName = [BNCSystemObserver getBrand];
43-
self.modelName = [BNCSystemObserver getModel];
44-
self.osName = [BNCSystemObserver getOS];
45-
self.osVersion = [BNCSystemObserver getOSVersion];
46-
self.screenWidth = [BNCSystemObserver getScreenWidth];
47-
self.screenHeight = [BNCSystemObserver getScreenHeight];
48-
self.isAdTrackingEnabled = [BNCSystemObserver adTrackingSafe];
67+
68+
} else if (systemVersion < 10.0) {
69+
70+
NSString *rawLanguage = [[NSLocale preferredLanguages] firstObject];
71+
NSDictionary *languageDictionary = [NSLocale componentsFromLocaleIdentifier:rawLanguage];
72+
self.country = [languageDictionary objectForKey:@"kCFLocaleCountryCodeKey"];
73+
self.language = [languageDictionary objectForKey:@"kCFLocaleLanguageCodeKey"];
74+
75+
} else {
76+
77+
self.country = [NSLocale currentLocale].countryCode;
78+
self.language = [NSLocale currentLocale].languageCode;
79+
4980
}
81+
82+
self.browserUserAgent =
83+
[[[UIWebView alloc]
84+
initWithFrame:CGRectZero]
85+
stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
86+
5087
return self;
5188
}
5289

Branch-SDK/Branch-SDK/BNCServerInterface.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,11 @@ - (void)updateDeviceInfoToMutableDictionary:(NSMutableDictionary *)dict {
298298
[self safeSetValue:deviceInfo.osVersion forKey:BRANCH_REQUEST_KEY_OS_VERSION onDict:dict];
299299
[self safeSetValue:deviceInfo.screenWidth forKey:BRANCH_REQUEST_KEY_SCREEN_WIDTH onDict:dict];
300300
[self safeSetValue:deviceInfo.screenHeight forKey:BRANCH_REQUEST_KEY_SCREEN_HEIGHT onDict:dict];
301-
301+
302+
[self safeSetValue:deviceInfo.browserUserAgent forKey:@"user_agent" onDict:dict];
303+
[self safeSetValue:deviceInfo.country forKey:@"country" onDict:dict];
304+
[self safeSetValue:deviceInfo.language forKey:@"language" onDict:dict];
305+
302306
dict[BRANCH_REQUEST_KEY_AD_TRACKING_ENABLED] = @(deviceInfo.isAdTrackingEnabled);
303307

304308
}

Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
67486B8D1B93B48A0044D872 /* BNCStrongMatchHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 67486B8B1B93B48A0044D872 /* BNCStrongMatchHelper.h */; };
113113
67486B8E1B93B48A0044D872 /* BNCStrongMatchHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 67486B8C1B93B48A0044D872 /* BNCStrongMatchHelper.m */; };
114114
677F4CB51C1FB1910029F2B3 /* Branch-TestBed.entitlements in Resources */ = {isa = PBXBuildFile; fileRef = 677F4CB41C1FB0FA0029F2B3 /* Branch-TestBed.entitlements */; };
115-
67F270891BA9FCFF002546A7 /* CoreSpotlight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 67F270881BA9FCFF002546A7 /* CoreSpotlight.framework */; settings = {ATTRIBUTES = (Required, ); }; };
115+
67F270891BA9FCFF002546A7 /* CoreSpotlight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 67F270881BA9FCFF002546A7 /* CoreSpotlight.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
116116
7D0C97191D8753C9004E14B1 /* BranchContentDiscoverer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D0C97181D8753C9004E14B1 /* BranchContentDiscoverer.m */; };
117117
7D0C971D1D875465004E14B1 /* BranchContentDiscoveryManifest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D0C971C1D875465004E14B1 /* BranchContentDiscoveryManifest.m */; };
118118
7D0C97201D87549B004E14B1 /* BranchContentPathProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D0C971F1D87549B004E14B1 /* BranchContentPathProperties.m */; };

ChangeLog.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
Branch iOS SDK change log
22

3+
- v0.12.13
4+
* AIS-106: Included user_agent in device POST parameters.
5+
* AIS-109: Included language & country in device POST parameters.
6+
* INT-2882: Moved Branch support files from Documents directory to Application Support directory.
7+
* Github #487: Updated documentation to mention that application:willFinishLaunchingWithOptions:
8+
also has to return YES on app launch.
39
- v0.12.12
410
* Updated Swift example to Swift 3.0
511
* Updated Update README.md Documentation Syntax for Swift
@@ -18,7 +24,7 @@ Branch iOS SDK change log
1824
- v0.12.10
1925
* Fix for issue causing initsession hang on cold start from universal link
2026
* Adding few crash protection
21-
* Removing BUO nullable fields
27+
* Removing BUO nullable fields
2228

2329
- v0.12.9
2430
* Fixing the time delay for strong match check using SVC
@@ -37,7 +43,7 @@ Branch iOS SDK change log
3743
* Remove debug gesture
3844
* Better instrumentation on retries
3945
* Add checksumming to the release procedure
40-
* Fix Branch & Mopub Fabric header conflict
46+
* Fix Branch & Mopub Fabric header conflict
4147
* Nullability and nonnull support for Swift
4248
* Add campaign to link properties
4349
* iOS 10 optimizations
@@ -47,7 +53,7 @@ Branch iOS SDK change log
4753
* fix module.map path on Carthage project
4854
* ability to whitelist URI schemes
4955

50-
- v0.12.4
56+
- v0.12.4
5157
* setDebug must be called on getInstance. It's no longer a static method.
5258
* referral code and promo code methods are no longer available
5359
* action count methods are no longer available
@@ -60,7 +66,7 @@ Branch iOS SDK change log
6066
- v0.12.3
6167
* Fabric Answers integration
6268
* Swift Testbed
63-
* Retry in poor network conditions
69+
* Retry in poor network conditions
6470
* Fix for Facebook calling openUrl from within the app
6571
* Fix Fabric headers conflict
6672
* Simplify Carthage project
@@ -111,7 +117,7 @@ Branch iOS SDK change log
111117
* workaround for Facebook sometimes returning NO from didFinishLaunching
112118
* spotlight IDs optionally returned in indexing callbacks
113119
* added ability to have custom parameters appear in deeplink data for debugging
114-
* removed fftl
120+
* removed fftl
115121
* added externalIntentURI to capture referrals
116122

117123
- v0.11.13
@@ -128,7 +134,7 @@ Branch iOS SDK change log
128134
* Set email subject on share sheet
129135
* 100% matching prototype. Woo!
130136
* BRanchUniversalObject with only canonical url allowed
131-
* Update register-view call so it's no longer a flat object
137+
* Update register-view call so it's no longer a flat object
132138
* Fix debug tests
133139
* Fix setUserUrl capitalization
134140
* TeamID can be gotten from plist or original way
@@ -162,7 +168,7 @@ Branch iOS SDK change log
162168
* easy listing for Spotlight search
163169
* fixed bugs / made additions for debug mode
164170
* squashed annoying warnings that some users saw
165-
* safer unarchiving of saved info (BNCPreferenceHelper)
171+
* safer unarchiving of saved info (BNCPreferenceHelper)
166172

167173
- v0.11.6
168174
* fix race condition if certain methods are invoked before initSession
@@ -227,7 +233,7 @@ Branch iOS SDK change log
227233
* If isReferrable is false, it will not be set.
228234
* If the session data returned from the API call is empty, it will not be set.
229235
* If the session data is not from a link click, it will not be set.
230-
* If the request is an open request, it will only be set if install params are empty.
236+
* If the request is an open request, it will only be set if install params are empty.
231237

232238
- v0.10.2
233239
* Fixing potential for bad types to come through in UserIdentity (number rather than string).

ReleaseNotes.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@
22
Branch SDK Release Notes
33
========================
44

5+
6+
* Check the change log for specific fixes: [Change log on Github.](https://github.com/BranchMetrics/ios-branch-deep-linking/blob/master/ChangeLog.md)
7+
8+
9+
#### Branch Version 0.12.13
10+
Better Match keys, Better Documentation - Tuesday, October 25 2016
11+
12+
* There are no breaking changes in this release.
13+
14+
* There are no significant new features in this release.
15+
16+
517
#### Branch Version 0.12.12
6-
Bug fixes, Swift Updates, and iOS 10 Compatibility – Tuesday, October 11 2016
18+
Bug Fixes, Swift Updates, and iOS 10 Compatibility – Tuesday, October 11 2016
719

8-
* There are no breaking changes in this release.
20+
* There are no breaking changes in this release.
921

10-
* The Swift example and documentation have been updated for Swift 3.0.
22+
* The Swift example and documentation have been updated for Swift 3.0.
1123

12-
* We've diagnosed an open problem when Branch, Localytics, and Google Analytics are all used
13-
in the same app. You can read the details and work-arounds in the Github issue
14-
[Branch, Localytics, and Google Analytics.](https://github.com/BranchMetrics/ios-branch-deep-linking/issues/485)
24+
* We've diagnosed an open problem when Branch, Localytics, and Google Analytics are all used
25+
in the same app. You can read the details and work-arounds in the Github issue
26+
[Branch, Localytics, and Google Analytics.](https://github.com/BranchMetrics/ios-branch-deep-linking/issues/485)
1527

16-
* Check the change log for specific fixes: [Change log on Github.](https://github.com/BranchMetrics/ios-branch-deep-linking/blob/master/ChangeLog.md)

0 commit comments

Comments
 (0)