Skip to content

Commit

Permalink
Merge pull request #377 from BranchMetrics/update-versions
Browse files Browse the repository at this point in the history
chore: update ios 0.19.5
  • Loading branch information
ethanneff authored Oct 2, 2017
2 parents 4cebdcf + 872f6da commit 4982186
Show file tree
Hide file tree
Showing 72 changed files with 437 additions and 253 deletions.
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/BNCCommerceEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//


#import <Foundation/Foundation.h>
@import Foundation;
#import "BNCServerRequest.h"


Expand Down
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/BNCConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2014 Branch Metrics. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;

extern NSString * const BNC_SDK_VERSION;
extern NSString * const BNC_API_BASE_URL;
Expand Down
4 changes: 2 additions & 2 deletions src/ios/dependencies/Branch-SDK/BNCConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// BNCConfig.c
// Branch-TestBed
//
// Created by edward on 12/12/16.
// Created by Edward Smith on 12/12/16.
// Copyright © 2016 Branch Metrics. All rights reserved.
//

Expand All @@ -11,4 +11,4 @@
NSString * const BNC_API_BASE_URL = @"https://api.branch.io";
NSString * const BNC_API_VERSION = @"v1";
NSString * const BNC_LINK_URL = @"https://bnc.lt";
NSString * const BNC_SDK_VERSION = @"0.18.8";
NSString * const BNC_SDK_VERSION = @"0.19.5";
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import "BranchConstants.h"

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000
#import <MobileCoreServices/MobileCoreServices.h>
@import MobileCoreServices;
#endif

#ifndef kUTTypeGeneric
Expand Down
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/BNCCrashlyticsWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017 Branch Metrics. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;

/**
* Convenience class to dynamically wrap the Crashlytics SDK
Expand Down
4 changes: 1 addition & 3 deletions src/ios/dependencies/Branch-SDK/BNCDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
*/
//--------------------------------------------------------------------------------------------------


#import <Foundation/Foundation.h>

@import Foundation;

#ifdef __cplusplus
extern "C" {
Expand Down
12 changes: 6 additions & 6 deletions src/ios/dependencies/Branch-SDK/BNCDebug.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


#import "BNCDebug.h"
#import <sys/sysctl.h>
#import <objc/runtime.h>
@import Darwin.sys.sysctl;
@import ObjectiveC.runtime;


BOOL BNCDebuggerIsAttached() {
Expand Down Expand Up @@ -60,7 +60,7 @@ BOOL BNCDebuggerIsAttached() {

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

const char* superclassname = "nil";
const char* superclassname = "<nil>";
Class class = object_getClass(instance);
Class superclass = class_getSuperclass(class);
if (superclass) superclassname = class_getName(superclass);
Expand All @@ -69,11 +69,11 @@ BOOL BNCDebuggerIsAttached() {
NSMutableString *result = [NSMutableString stringWithCapacity:512];
if (class_isMetaClass(class)) {
[result appendFormat:@"\nClass %p is class '%s' of class '%s':\n",
instance, class_getName(class), superclassname];
(void*)instance, class_getName(class), superclassname];
class = instance;
} else {
[result appendFormat:@"\nInstance %p is of class '%s' of class '%s':\n",
instance, class_getName(class), superclassname];
(void*)instance, class_getName(class), superclassname];
}

// Ivars --
Expand All @@ -94,7 +94,7 @@ BOOL BNCDebuggerIsAttached() {

uint count = 0;
Ivar *ivars = class_copyIvarList(class, &count);
for (int i = 0; i < count; ++i) {
for (uint i = 0; i < count; ++i) {
const char* encoding = ivar_getTypeEncoding(ivars[i]);
const char* ivarName = ivar_getName(ivars[i]);
const void* ivarPtr = nil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
// Created by Parth Kalavadia on 5/15/17.
// Copyright © 2017 Parth Kalavadia. All rights reserved.
//
#import <Foundation/Foundation.h>

@import Foundation;
#import "BranchDeepLinkingController.h"

@interface BNCDeepLinkViewControllerInstance : NSObject

@property (strong, nonatomic)UIViewController<BranchDeepLinkingController>* viewController;
Expand Down
20 changes: 7 additions & 13 deletions src/ios/dependencies/Branch-SDK/BNCDeviceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,16 @@
// Created by Sojan P.R. on 3/22/16.
// Copyright © 2016 Branch Metrics. All rights reserved.
//
#import <Foundation/Foundation.h>
#ifndef BNCDeviceInfo_h
#define BNCDeviceInfo_h



#endif /* BNCDeviceInfo_h */
@import Foundation;

@interface BNCDeviceInfo : NSObject

//---------Properties-------------//
@property (atomic, copy, readonly) NSString *hardwareId;
@property (atomic, copy, readonly) NSString *hardwareIdType;
@property (atomic, readonly) BOOL isRealHardwareId;
// vendorId can be nil initially and non-nil later.
@property (atomic, copy, readonly) NSString *vendorId;
@property (atomic, copy, readonly) NSString *vendorId; //!< VendorId can be nil initially and non-nil later.
@property (atomic, copy, readonly) NSString *brandName;
@property (atomic, copy, readonly) NSString *modelName;
@property (atomic, copy, readonly) NSString *osName;
Expand All @@ -29,11 +23,11 @@
@property (atomic, copy, readonly) NSNumber *screenHeight;
@property (atomic, readonly) BOOL isAdTrackingEnabled;

@property (atomic, copy, readonly) NSString* country; // iso2 Country name (us, in,etc).
@property (atomic, copy, readonly) NSString* language; // iso2 language code (en, ml).
@property (atomic, copy, readonly) NSString* browserUserAgent; // Simple user agent string.


@property (atomic, copy, readonly) NSString* country; //!< The iso2 Country name (us, in,etc).
@property (atomic, copy, readonly) NSString* language; //!< The iso2 language code (en, ml).
@property (atomic, copy, readonly) NSString* browserUserAgent; //!< Simple user agent string.
@property (atomic, copy, readonly) NSString* localIPAddress; //!< The current local IP address.
@property (atomic, copy, readonly) NSArray<NSString*> *allIPAddresses; //!< All local IP addresses.
//----------Methods----------------//
+ (BNCDeviceInfo *)getInstance;
+ (NSString*) userAgentString; // Warning: Has an implied lock on main thread on first call.
Expand Down
131 changes: 125 additions & 6 deletions src/ios/dependencies/Branch-SDK/BNCDeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,123 @@
// Copyright © 2016 Branch Metrics. All rights reserved.
//


#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <sys/sysctl.h>
#import "BNCDeviceInfo.h"
#import "BNCPreferenceHelper.h"
#import "BNCSystemObserver.h"
#import "BNCXcode7Support.h"
#import "BNCLog.h"

@import UIKit;
#import <sys/sysctl.h> // @import not available in Xcode 7
#import <net/if.h>
#import <ifaddrs.h>
#import <arpa/inet.h>
#import <netinet/in.h>

#pragma mark BRNNetworkInfo

typedef NS_ENUM(NSInteger, BNCNetworkAddressType) {
BNCNetworkAddressTypeUnknown = 0,
BNCNetworkAddressTypeIPv4,
BNCNetworkAddressTypeIPv6
};

@interface BNCNetworkInterface : NSObject

+ (NSArray<BNCNetworkInterface*>*) currentInterfaces;

@property (nonatomic, strong) NSString *interfaceName;
@property (nonatomic, assign) BNCNetworkAddressType addressType;
@property (nonatomic, strong) NSString *address;
@end

@implementation BNCNetworkInterface

+ (NSArray<BNCNetworkInterface*>*) currentInterfaces {

struct ifaddrs *interfaces = NULL;
NSMutableArray *currentInterfaces = [NSMutableArray arrayWithCapacity:8];

// Retrieve the current interfaces - returns 0 on success

if (getifaddrs(&interfaces) != 0) {
int e = errno;
BNCLogError(@"Can't read ip address: (%d): %s.", e, strerror(e));
goto exit;
}

// Loop through linked list of interfaces --

struct ifaddrs *interface = NULL;
for(interface=interfaces; interface; interface=interface->ifa_next) {
// BNCLogDebugSDK(@"Found %s: %x.", interface->ifa_name, interface->ifa_flags);

// Check the state: IFF_RUNNING, IFF_UP, IFF_LOOPBACK, etc.
if ((interface->ifa_flags & IFF_UP) &&
(interface->ifa_flags & IFF_RUNNING) &&
!(interface->ifa_flags & IFF_LOOPBACK)) {
} else {
continue;
}

// TODO: Check ifdata too.
// struct if_data *ifdata = interface->ifa_data;

const struct sockaddr_in *addr = (const struct sockaddr_in*)interface->ifa_addr;
if (!addr) continue;

BNCNetworkAddressType type = BNCNetworkAddressTypeUnknown;
char addrBuf[ MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) ];

if (addr->sin_family == AF_INET) {
if (inet_ntop(AF_INET, &addr->sin_addr, addrBuf, INET_ADDRSTRLEN))
type = BNCNetworkAddressTypeIPv4;
}
else
if (addr->sin_family == AF_INET6) {
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6*)interface->ifa_addr;
if (inet_ntop(AF_INET6, &addr6->sin6_addr, addrBuf, INET6_ADDRSTRLEN))
type = BNCNetworkAddressTypeIPv6;
}
else {
continue;
}

NSString *name = [NSString stringWithUTF8String:interface->ifa_name];
if (name && type != BNCNetworkAddressTypeUnknown) {
BNCNetworkInterface *interface = [BNCNetworkInterface new];
interface.interfaceName = name;
interface.addressType = type;
interface.address = [NSString stringWithUTF8String:addrBuf];
[currentInterfaces addObject:interface];
}
}

exit:
if (interfaces) freeifaddrs(interfaces);
return currentInterfaces;
}

- (NSString*) description {
return [NSString stringWithFormat:@"<%@ %p %@ %@>",
NSStringFromClass(self.class),
self,
self.interfaceName,
self.address
];
}

@end

#pragma mark - BNCDeviceInfo

@interface BNCDeviceInfo()
@end


@implementation BNCDeviceInfo {
NSString * volatile _vendorId;
NSString *_vendorId;
NSString *_localIPAddress;
}

+ (BNCDeviceInfo *)getInstance {
Expand Down Expand Up @@ -84,6 +184,25 @@ - (NSString *)vendorId {
}
}

- (NSString*) localIPAddress { // For 'local_ip' server field.
@synchronized (self) {
NSArray<BNCNetworkInterface*>*interfaces = [BNCNetworkInterface currentInterfaces];
for (BNCNetworkInterface *interface in interfaces) {
if (interface.addressType == BNCNetworkAddressTypeIPv4)
return interface.address;
}
return nil;
}
}

- (NSArray<NSString*>*) allIPAddresses {
NSMutableArray *array = [NSMutableArray new];
for (BNCNetworkInterface *inf in [BNCNetworkInterface currentInterfaces]) {
[array addObject:inf.description];
}
return array;
}

+ (NSString*) bnc_country {

NSString *country = nil;
Expand Down Expand Up @@ -229,7 +348,7 @@ + (NSString*) userAgentString {
}

// Different case for iOS 7.0:
if ([UIDevice currentDevice].systemVersion.floatValue < 8.0) {
if ([UIDevice currentDevice].systemVersion.doubleValue < 8.0) {
BNCLogDebugSDK(@"Getting iOS 7 UserAgent.");
dispatch_sync(dispatch_get_main_queue(), ^ {
setBrowserUserAgent();
Expand Down
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/BNCEncodingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Branch Metrics. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;

#pragma mark BNCKeyValue

Expand Down
9 changes: 5 additions & 4 deletions src/ios/dependencies/Branch-SDK/BNCEncodingUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ - (NSString*) description {
return [NSString stringWithFormat:@"<%@, %@>", self.key, self.value];
}

- (BOOL) isEqual:(BNCKeyValue*)object {
- (BOOL) isEqual:(id)rawObject {
BNCKeyValue *object = rawObject;
return
[object isKindOfClass:[BNCKeyValue class]] &&
[self.key isEqualToString:object.key] &&
Expand Down Expand Up @@ -391,8 +392,8 @@ + (NSData *) dataFromHexString:(NSString*)string {
if (!bytes) goto exit;

int highValue = -1;
uint8_t *p = (uint8_t*) [inputData bytes];
for (long i = 0; i < inputData.length; ++i) {
const uint8_t *p = (const uint8_t*) [inputData bytes];
for (NSUInteger i = 0; i < inputData.length; ++i) {
int value = -1;
if (*p >= '0' && *p <= '9')
value = *p - '0';
Expand Down Expand Up @@ -425,7 +426,7 @@ + (NSData *) dataFromHexString:(NSString*)string {

exit:
if (bytes) {
BNCLogAssert(b-bytes<=length);
BNCLogAssert((size_t)(b-bytes)<=length);
free(bytes);
}
return data;
Expand Down
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/BNCError.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2014 Branch Metrics. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;

FOUNDATION_EXPORT NSString *_Nonnull const BNCErrorDomain;

Expand Down
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/BNCFabricAnswers.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2016 Branch Metrics. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;

@interface BNCFabricAnswers : NSObject

Expand Down
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/BNCLinkCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Branch Metrics. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;
#import "BNCLinkData.h"

@interface BNCLinkCache : NSObject
Expand Down
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/BNCLinkCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ @interface BNCLinkCache ()
@implementation BNCLinkCache

- (id)init {
if (self = [super init]) {
if ((self = [super init])) {
self.cache = [[NSMutableDictionary alloc] init];
}
return self;
Expand Down
Loading

0 comments on commit 4982186

Please sign in to comment.