Skip to content

Commit 4982186

Browse files
authored
Merge pull request #377 from BranchMetrics/update-versions
chore: update ios 0.19.5
2 parents 4cebdcf + 872f6da commit 4982186

File tree

72 files changed

+437
-253
lines changed

Some content is hidden

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

72 files changed

+437
-253
lines changed

src/ios/dependencies/Branch-SDK/BNCCommerceEvent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99

10-
#import <Foundation/Foundation.h>
10+
@import Foundation;
1111
#import "BNCServerRequest.h"
1212

1313

src/ios/dependencies/Branch-SDK/BNCConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright (c) 2014 Branch Metrics. All rights reserved.
77
//
88

9-
#import <Foundation/Foundation.h>
9+
@import Foundation;
1010

1111
extern NSString * const BNC_SDK_VERSION;
1212
extern NSString * const BNC_API_BASE_URL;

src/ios/dependencies/Branch-SDK/BNCConfig.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// BNCConfig.c
33
// Branch-TestBed
44
//
5-
// Created by edward on 12/12/16.
5+
// Created by Edward Smith on 12/12/16.
66
// Copyright © 2016 Branch Metrics. All rights reserved.
77
//
88

@@ -11,4 +11,4 @@
1111
NSString * const BNC_API_BASE_URL = @"https://api.branch.io";
1212
NSString * const BNC_API_VERSION = @"v1";
1313
NSString * const BNC_LINK_URL = @"https://bnc.lt";
14-
NSString * const BNC_SDK_VERSION = @"0.18.8";
14+
NSString * const BNC_SDK_VERSION = @"0.19.5";

src/ios/dependencies/Branch-SDK/BNCContentDiscoveryManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#import "BranchConstants.h"
1414

1515
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000
16-
#import <MobileCoreServices/MobileCoreServices.h>
16+
@import MobileCoreServices;
1717
#endif
1818

1919
#ifndef kUTTypeGeneric

src/ios/dependencies/Branch-SDK/BNCCrashlyticsWrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2017 Branch Metrics. All rights reserved.
77
//
88

9-
#import <Foundation/Foundation.h>
9+
@import Foundation;
1010

1111
/**
1212
* Convenience class to dynamically wrap the Crashlytics SDK

src/ios/dependencies/Branch-SDK/BNCDebug.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@
4848
*/
4949
//--------------------------------------------------------------------------------------------------
5050

51-
52-
#import <Foundation/Foundation.h>
53-
51+
@import Foundation;
5452

5553
#ifdef __cplusplus
5654
extern "C" {

src/ios/dependencies/Branch-SDK/BNCDebug.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515

1616
#import "BNCDebug.h"
17-
#import <sys/sysctl.h>
18-
#import <objc/runtime.h>
17+
@import Darwin.sys.sysctl;
18+
@import ObjectiveC.runtime;
1919

2020

2121
BOOL BNCDebuggerIsAttached() {
@@ -60,7 +60,7 @@ BOOL BNCDebuggerIsAttached() {
6060

6161
if (!instance) return @"Object is nil.\n";
6262

63-
const char* superclassname = "nil";
63+
const char* superclassname = "<nil>";
6464
Class class = object_getClass(instance);
6565
Class superclass = class_getSuperclass(class);
6666
if (superclass) superclassname = class_getName(superclass);
@@ -69,11 +69,11 @@ BOOL BNCDebuggerIsAttached() {
6969
NSMutableString *result = [NSMutableString stringWithCapacity:512];
7070
if (class_isMetaClass(class)) {
7171
[result appendFormat:@"\nClass %p is class '%s' of class '%s':\n",
72-
instance, class_getName(class), superclassname];
72+
(void*)instance, class_getName(class), superclassname];
7373
class = instance;
7474
} else {
7575
[result appendFormat:@"\nInstance %p is of class '%s' of class '%s':\n",
76-
instance, class_getName(class), superclassname];
76+
(void*)instance, class_getName(class), superclassname];
7777
}
7878

7979
// Ivars --
@@ -94,7 +94,7 @@ BOOL BNCDebuggerIsAttached() {
9494

9595
uint count = 0;
9696
Ivar *ivars = class_copyIvarList(class, &count);
97-
for (int i = 0; i < count; ++i) {
97+
for (uint i = 0; i < count; ++i) {
9898
const char* encoding = ivar_getTypeEncoding(ivars[i]);
9999
const char* ivarName = ivar_getName(ivars[i]);
100100
const void* ivarPtr = nil;

src/ios/dependencies/Branch-SDK/BNCDeepLinkViewControllerInstance.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
// Created by Parth Kalavadia on 5/15/17.
66
// Copyright © 2017 Parth Kalavadia. All rights reserved.
77
//
8-
#import <Foundation/Foundation.h>
8+
9+
@import Foundation;
910
#import "BranchDeepLinkingController.h"
11+
1012
@interface BNCDeepLinkViewControllerInstance : NSObject
1113

1214
@property (strong, nonatomic)UIViewController<BranchDeepLinkingController>* viewController;

src/ios/dependencies/Branch-SDK/BNCDeviceInfo.h

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,16 @@
55
// Created by Sojan P.R. on 3/22/16.
66
// Copyright © 2016 Branch Metrics. All rights reserved.
77
//
8-
#import <Foundation/Foundation.h>
9-
#ifndef BNCDeviceInfo_h
10-
#define BNCDeviceInfo_h
118

12-
13-
14-
#endif /* BNCDeviceInfo_h */
9+
@import Foundation;
1510

1611
@interface BNCDeviceInfo : NSObject
1712

1813
//---------Properties-------------//
1914
@property (atomic, copy, readonly) NSString *hardwareId;
2015
@property (atomic, copy, readonly) NSString *hardwareIdType;
2116
@property (atomic, readonly) BOOL isRealHardwareId;
22-
// vendorId can be nil initially and non-nil later.
23-
@property (atomic, copy, readonly) NSString *vendorId;
17+
@property (atomic, copy, readonly) NSString *vendorId; //!< VendorId can be nil initially and non-nil later.
2418
@property (atomic, copy, readonly) NSString *brandName;
2519
@property (atomic, copy, readonly) NSString *modelName;
2620
@property (atomic, copy, readonly) NSString *osName;
@@ -29,11 +23,11 @@
2923
@property (atomic, copy, readonly) NSNumber *screenHeight;
3024
@property (atomic, readonly) BOOL isAdTrackingEnabled;
3125

32-
@property (atomic, copy, readonly) NSString* country; // iso2 Country name (us, in,etc).
33-
@property (atomic, copy, readonly) NSString* language; // iso2 language code (en, ml).
34-
@property (atomic, copy, readonly) NSString* browserUserAgent; // Simple user agent string.
35-
36-
26+
@property (atomic, copy, readonly) NSString* country; //!< The iso2 Country name (us, in,etc).
27+
@property (atomic, copy, readonly) NSString* language; //!< The iso2 language code (en, ml).
28+
@property (atomic, copy, readonly) NSString* browserUserAgent; //!< Simple user agent string.
29+
@property (atomic, copy, readonly) NSString* localIPAddress; //!< The current local IP address.
30+
@property (atomic, copy, readonly) NSArray<NSString*> *allIPAddresses; //!< All local IP addresses.
3731
//----------Methods----------------//
3832
+ (BNCDeviceInfo *)getInstance;
3933
+ (NSString*) userAgentString; // Warning: Has an implied lock on main thread on first call.

src/ios/dependencies/Branch-SDK/BNCDeviceInfo.m

Lines changed: 125 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,123 @@
66
// Copyright © 2016 Branch Metrics. All rights reserved.
77
//
88

9-
10-
#import <Foundation/Foundation.h>
11-
#import <UIKit/UIKit.h>
12-
#import <sys/sysctl.h>
139
#import "BNCDeviceInfo.h"
1410
#import "BNCPreferenceHelper.h"
1511
#import "BNCSystemObserver.h"
1612
#import "BNCXcode7Support.h"
1713
#import "BNCLog.h"
1814

15+
@import UIKit;
16+
#import <sys/sysctl.h> // @import not available in Xcode 7
17+
#import <net/if.h>
18+
#import <ifaddrs.h>
19+
#import <arpa/inet.h>
20+
#import <netinet/in.h>
21+
22+
#pragma mark BRNNetworkInfo
23+
24+
typedef NS_ENUM(NSInteger, BNCNetworkAddressType) {
25+
BNCNetworkAddressTypeUnknown = 0,
26+
BNCNetworkAddressTypeIPv4,
27+
BNCNetworkAddressTypeIPv6
28+
};
29+
30+
@interface BNCNetworkInterface : NSObject
31+
32+
+ (NSArray<BNCNetworkInterface*>*) currentInterfaces;
33+
34+
@property (nonatomic, strong) NSString *interfaceName;
35+
@property (nonatomic, assign) BNCNetworkAddressType addressType;
36+
@property (nonatomic, strong) NSString *address;
37+
@end
38+
39+
@implementation BNCNetworkInterface
40+
41+
+ (NSArray<BNCNetworkInterface*>*) currentInterfaces {
42+
43+
struct ifaddrs *interfaces = NULL;
44+
NSMutableArray *currentInterfaces = [NSMutableArray arrayWithCapacity:8];
45+
46+
// Retrieve the current interfaces - returns 0 on success
47+
48+
if (getifaddrs(&interfaces) != 0) {
49+
int e = errno;
50+
BNCLogError(@"Can't read ip address: (%d): %s.", e, strerror(e));
51+
goto exit;
52+
}
53+
54+
// Loop through linked list of interfaces --
55+
56+
struct ifaddrs *interface = NULL;
57+
for(interface=interfaces; interface; interface=interface->ifa_next) {
58+
// BNCLogDebugSDK(@"Found %s: %x.", interface->ifa_name, interface->ifa_flags);
59+
60+
// Check the state: IFF_RUNNING, IFF_UP, IFF_LOOPBACK, etc.
61+
if ((interface->ifa_flags & IFF_UP) &&
62+
(interface->ifa_flags & IFF_RUNNING) &&
63+
!(interface->ifa_flags & IFF_LOOPBACK)) {
64+
} else {
65+
continue;
66+
}
67+
68+
// TODO: Check ifdata too.
69+
// struct if_data *ifdata = interface->ifa_data;
70+
71+
const struct sockaddr_in *addr = (const struct sockaddr_in*)interface->ifa_addr;
72+
if (!addr) continue;
73+
74+
BNCNetworkAddressType type = BNCNetworkAddressTypeUnknown;
75+
char addrBuf[ MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) ];
76+
77+
if (addr->sin_family == AF_INET) {
78+
if (inet_ntop(AF_INET, &addr->sin_addr, addrBuf, INET_ADDRSTRLEN))
79+
type = BNCNetworkAddressTypeIPv4;
80+
}
81+
else
82+
if (addr->sin_family == AF_INET6) {
83+
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6*)interface->ifa_addr;
84+
if (inet_ntop(AF_INET6, &addr6->sin6_addr, addrBuf, INET6_ADDRSTRLEN))
85+
type = BNCNetworkAddressTypeIPv6;
86+
}
87+
else {
88+
continue;
89+
}
90+
91+
NSString *name = [NSString stringWithUTF8String:interface->ifa_name];
92+
if (name && type != BNCNetworkAddressTypeUnknown) {
93+
BNCNetworkInterface *interface = [BNCNetworkInterface new];
94+
interface.interfaceName = name;
95+
interface.addressType = type;
96+
interface.address = [NSString stringWithUTF8String:addrBuf];
97+
[currentInterfaces addObject:interface];
98+
}
99+
}
100+
101+
exit:
102+
if (interfaces) freeifaddrs(interfaces);
103+
return currentInterfaces;
104+
}
105+
106+
- (NSString*) description {
107+
return [NSString stringWithFormat:@"<%@ %p %@ %@>",
108+
NSStringFromClass(self.class),
109+
self,
110+
self.interfaceName,
111+
self.address
112+
];
113+
}
114+
115+
@end
116+
117+
#pragma mark - BNCDeviceInfo
19118

20119
@interface BNCDeviceInfo()
21120
@end
22121

23122

24123
@implementation BNCDeviceInfo {
25-
NSString * volatile _vendorId;
124+
NSString *_vendorId;
125+
NSString *_localIPAddress;
26126
}
27127

28128
+ (BNCDeviceInfo *)getInstance {
@@ -84,6 +184,25 @@ - (NSString *)vendorId {
84184
}
85185
}
86186

187+
- (NSString*) localIPAddress { // For 'local_ip' server field.
188+
@synchronized (self) {
189+
NSArray<BNCNetworkInterface*>*interfaces = [BNCNetworkInterface currentInterfaces];
190+
for (BNCNetworkInterface *interface in interfaces) {
191+
if (interface.addressType == BNCNetworkAddressTypeIPv4)
192+
return interface.address;
193+
}
194+
return nil;
195+
}
196+
}
197+
198+
- (NSArray<NSString*>*) allIPAddresses {
199+
NSMutableArray *array = [NSMutableArray new];
200+
for (BNCNetworkInterface *inf in [BNCNetworkInterface currentInterfaces]) {
201+
[array addObject:inf.description];
202+
}
203+
return array;
204+
}
205+
87206
+ (NSString*) bnc_country {
88207

89208
NSString *country = nil;
@@ -229,7 +348,7 @@ + (NSString*) userAgentString {
229348
}
230349

231350
// Different case for iOS 7.0:
232-
if ([UIDevice currentDevice].systemVersion.floatValue < 8.0) {
351+
if ([UIDevice currentDevice].systemVersion.doubleValue < 8.0) {
233352
BNCLogDebugSDK(@"Getting iOS 7 UserAgent.");
234353
dispatch_sync(dispatch_get_main_queue(), ^ {
235354
setBrowserUserAgent();

0 commit comments

Comments
 (0)