diff --git a/src/ios/dependencies/Branch-SDK/BNCCommerceEvent.h b/src/ios/dependencies/Branch-SDK/BNCCommerceEvent.h index 4a0118ef..a800cc48 100644 --- a/src/ios/dependencies/Branch-SDK/BNCCommerceEvent.h +++ b/src/ios/dependencies/Branch-SDK/BNCCommerceEvent.h @@ -7,7 +7,7 @@ // -#import +@import Foundation; #import "BNCServerRequest.h" diff --git a/src/ios/dependencies/Branch-SDK/BNCConfig.h b/src/ios/dependencies/Branch-SDK/BNCConfig.h index f1975131..c525a2a9 100644 --- a/src/ios/dependencies/Branch-SDK/BNCConfig.h +++ b/src/ios/dependencies/Branch-SDK/BNCConfig.h @@ -6,7 +6,7 @@ // Copyright (c) 2014 Branch Metrics. All rights reserved. // -#import +@import Foundation; extern NSString * const BNC_SDK_VERSION; extern NSString * const BNC_API_BASE_URL; diff --git a/src/ios/dependencies/Branch-SDK/BNCConfig.m b/src/ios/dependencies/Branch-SDK/BNCConfig.m index 891d51d7..e7eeac1f 100644 --- a/src/ios/dependencies/Branch-SDK/BNCConfig.m +++ b/src/ios/dependencies/Branch-SDK/BNCConfig.m @@ -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. // @@ -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"; diff --git a/src/ios/dependencies/Branch-SDK/BNCContentDiscoveryManager.m b/src/ios/dependencies/Branch-SDK/BNCContentDiscoveryManager.m index fbd509f3..91bc3fbd 100644 --- a/src/ios/dependencies/Branch-SDK/BNCContentDiscoveryManager.m +++ b/src/ios/dependencies/Branch-SDK/BNCContentDiscoveryManager.m @@ -13,7 +13,7 @@ #import "BranchConstants.h" #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000 -#import +@import MobileCoreServices; #endif #ifndef kUTTypeGeneric diff --git a/src/ios/dependencies/Branch-SDK/BNCCrashlyticsWrapper.h b/src/ios/dependencies/Branch-SDK/BNCCrashlyticsWrapper.h index 7bd743ed..b87346ff 100644 --- a/src/ios/dependencies/Branch-SDK/BNCCrashlyticsWrapper.h +++ b/src/ios/dependencies/Branch-SDK/BNCCrashlyticsWrapper.h @@ -6,7 +6,7 @@ // Copyright © 2017 Branch Metrics. All rights reserved. // -#import +@import Foundation; /** * Convenience class to dynamically wrap the Crashlytics SDK diff --git a/src/ios/dependencies/Branch-SDK/BNCDebug.h b/src/ios/dependencies/Branch-SDK/BNCDebug.h index b696c882..5e2a487a 100644 --- a/src/ios/dependencies/Branch-SDK/BNCDebug.h +++ b/src/ios/dependencies/Branch-SDK/BNCDebug.h @@ -48,9 +48,7 @@ */ //-------------------------------------------------------------------------------------------------- - -#import - +@import Foundation; #ifdef __cplusplus extern "C" { diff --git a/src/ios/dependencies/Branch-SDK/BNCDebug.m b/src/ios/dependencies/Branch-SDK/BNCDebug.m index b991c382..e7a94b75 100644 --- a/src/ios/dependencies/Branch-SDK/BNCDebug.m +++ b/src/ios/dependencies/Branch-SDK/BNCDebug.m @@ -14,8 +14,8 @@ #import "BNCDebug.h" -#import -#import +@import Darwin.sys.sysctl; +@import ObjectiveC.runtime; BOOL BNCDebuggerIsAttached() { @@ -60,7 +60,7 @@ BOOL BNCDebuggerIsAttached() { if (!instance) return @"Object is nil.\n"; - const char* superclassname = "nil"; + const char* superclassname = ""; Class class = object_getClass(instance); Class superclass = class_getSuperclass(class); if (superclass) superclassname = class_getName(superclass); @@ -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 -- @@ -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; diff --git a/src/ios/dependencies/Branch-SDK/BNCDeepLinkViewControllerInstance.h b/src/ios/dependencies/Branch-SDK/BNCDeepLinkViewControllerInstance.h index b8c8130b..ad606dee 100644 --- a/src/ios/dependencies/Branch-SDK/BNCDeepLinkViewControllerInstance.h +++ b/src/ios/dependencies/Branch-SDK/BNCDeepLinkViewControllerInstance.h @@ -5,8 +5,10 @@ // Created by Parth Kalavadia on 5/15/17. // Copyright © 2017 Parth Kalavadia. All rights reserved. // -#import + +@import Foundation; #import "BranchDeepLinkingController.h" + @interface BNCDeepLinkViewControllerInstance : NSObject @property (strong, nonatomic)UIViewController* viewController; diff --git a/src/ios/dependencies/Branch-SDK/BNCDeviceInfo.h b/src/ios/dependencies/Branch-SDK/BNCDeviceInfo.h index 78c454a1..125aea78 100644 --- a/src/ios/dependencies/Branch-SDK/BNCDeviceInfo.h +++ b/src/ios/dependencies/Branch-SDK/BNCDeviceInfo.h @@ -5,13 +5,8 @@ // Created by Sojan P.R. on 3/22/16. // Copyright © 2016 Branch Metrics. All rights reserved. // -#import -#ifndef BNCDeviceInfo_h -#define BNCDeviceInfo_h - - -#endif /* BNCDeviceInfo_h */ +@import Foundation; @interface BNCDeviceInfo : NSObject @@ -19,8 +14,7 @@ @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; @@ -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 *allIPAddresses; //!< All local IP addresses. //----------Methods----------------// + (BNCDeviceInfo *)getInstance; + (NSString*) userAgentString; // Warning: Has an implied lock on main thread on first call. diff --git a/src/ios/dependencies/Branch-SDK/BNCDeviceInfo.m b/src/ios/dependencies/Branch-SDK/BNCDeviceInfo.m index 66ccdf6c..ec73e9bc 100644 --- a/src/ios/dependencies/Branch-SDK/BNCDeviceInfo.m +++ b/src/ios/dependencies/Branch-SDK/BNCDeviceInfo.m @@ -6,23 +6,123 @@ // Copyright © 2016 Branch Metrics. All rights reserved. // - -#import -#import -#import #import "BNCDeviceInfo.h" #import "BNCPreferenceHelper.h" #import "BNCSystemObserver.h" #import "BNCXcode7Support.h" #import "BNCLog.h" +@import UIKit; +#import // @import not available in Xcode 7 +#import +#import +#import +#import + +#pragma mark BRNNetworkInfo + +typedef NS_ENUM(NSInteger, BNCNetworkAddressType) { + BNCNetworkAddressTypeUnknown = 0, + BNCNetworkAddressTypeIPv4, + BNCNetworkAddressTypeIPv6 +}; + +@interface BNCNetworkInterface : NSObject + ++ (NSArray*) currentInterfaces; + +@property (nonatomic, strong) NSString *interfaceName; +@property (nonatomic, assign) BNCNetworkAddressType addressType; +@property (nonatomic, strong) NSString *address; +@end + +@implementation BNCNetworkInterface + ++ (NSArray*) 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 { @@ -84,6 +184,25 @@ - (NSString *)vendorId { } } +- (NSString*) localIPAddress { // For 'local_ip' server field. + @synchronized (self) { + NSArray*interfaces = [BNCNetworkInterface currentInterfaces]; + for (BNCNetworkInterface *interface in interfaces) { + if (interface.addressType == BNCNetworkAddressTypeIPv4) + return interface.address; + } + return nil; + } +} + +- (NSArray*) allIPAddresses { + NSMutableArray *array = [NSMutableArray new]; + for (BNCNetworkInterface *inf in [BNCNetworkInterface currentInterfaces]) { + [array addObject:inf.description]; + } + return array; +} + + (NSString*) bnc_country { NSString *country = nil; @@ -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(); diff --git a/src/ios/dependencies/Branch-SDK/BNCEncodingUtils.h b/src/ios/dependencies/Branch-SDK/BNCEncodingUtils.h index b50f0eef..2efcf47f 100644 --- a/src/ios/dependencies/Branch-SDK/BNCEncodingUtils.h +++ b/src/ios/dependencies/Branch-SDK/BNCEncodingUtils.h @@ -6,7 +6,7 @@ // Copyright (c) 2015 Branch Metrics. All rights reserved. // -#import +@import Foundation; #pragma mark BNCKeyValue diff --git a/src/ios/dependencies/Branch-SDK/BNCEncodingUtils.m b/src/ios/dependencies/Branch-SDK/BNCEncodingUtils.m index f301972b..c7bc4a1d 100644 --- a/src/ios/dependencies/Branch-SDK/BNCEncodingUtils.m +++ b/src/ios/dependencies/Branch-SDK/BNCEncodingUtils.m @@ -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] && @@ -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'; @@ -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; diff --git a/src/ios/dependencies/Branch-SDK/BNCError.h b/src/ios/dependencies/Branch-SDK/BNCError.h index 5bd5803c..160be990 100644 --- a/src/ios/dependencies/Branch-SDK/BNCError.h +++ b/src/ios/dependencies/Branch-SDK/BNCError.h @@ -6,7 +6,7 @@ // Copyright (c) 2014 Branch Metrics. All rights reserved. // -#import +@import Foundation; FOUNDATION_EXPORT NSString *_Nonnull const BNCErrorDomain; diff --git a/src/ios/dependencies/Branch-SDK/BNCFabricAnswers.h b/src/ios/dependencies/Branch-SDK/BNCFabricAnswers.h index c7e74ddd..03aa6d22 100644 --- a/src/ios/dependencies/Branch-SDK/BNCFabricAnswers.h +++ b/src/ios/dependencies/Branch-SDK/BNCFabricAnswers.h @@ -6,7 +6,7 @@ // Copyright © 2016 Branch Metrics. All rights reserved. // -#import +@import Foundation; @interface BNCFabricAnswers : NSObject diff --git a/src/ios/dependencies/Branch-SDK/BNCLinkCache.h b/src/ios/dependencies/Branch-SDK/BNCLinkCache.h index ed725b39..cd60ef00 100644 --- a/src/ios/dependencies/Branch-SDK/BNCLinkCache.h +++ b/src/ios/dependencies/Branch-SDK/BNCLinkCache.h @@ -6,7 +6,7 @@ // Copyright (c) 2015 Branch Metrics. All rights reserved. // -#import +@import Foundation; #import "BNCLinkData.h" @interface BNCLinkCache : NSObject diff --git a/src/ios/dependencies/Branch-SDK/BNCLinkCache.m b/src/ios/dependencies/Branch-SDK/BNCLinkCache.m index e09cf7db..73169d21 100644 --- a/src/ios/dependencies/Branch-SDK/BNCLinkCache.m +++ b/src/ios/dependencies/Branch-SDK/BNCLinkCache.m @@ -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; diff --git a/src/ios/dependencies/Branch-SDK/BNCLinkData.h b/src/ios/dependencies/Branch-SDK/BNCLinkData.h index d59dab2c..3893e12a 100644 --- a/src/ios/dependencies/Branch-SDK/BNCLinkData.h +++ b/src/ios/dependencies/Branch-SDK/BNCLinkData.h @@ -6,7 +6,7 @@ // Copyright (c) 2015 Branch Metrics. All rights reserved. // -#import +@import Foundation; typedef NS_ENUM(NSUInteger, BranchLinkType) { BranchLinkTypeUnlimitedUse = 0, diff --git a/src/ios/dependencies/Branch-SDK/BNCLinkData.m b/src/ios/dependencies/Branch-SDK/BNCLinkData.m index 8620aaa6..ad976a38 100644 --- a/src/ios/dependencies/Branch-SDK/BNCLinkData.m +++ b/src/ios/dependencies/Branch-SDK/BNCLinkData.m @@ -29,7 +29,7 @@ @interface BNCLinkData () @implementation BNCLinkData - (id)init { - if (self = [super init]) { + if ((self = [super init])) { self.data = [[NSMutableDictionary alloc] init]; self.data[@"source"] = @"ios"; } @@ -169,7 +169,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { } - (id)initWithCoder:(NSCoder *)coder { - if (self = [super init]) { + if ((self = [super init])) { self.tags = [coder decodeObjectForKey:BRANCH_REQUEST_KEY_URL_TAGS]; self.alias = [coder decodeObjectForKey:BRANCH_REQUEST_KEY_URL_ALIAS]; self.type = [[coder decodeObjectForKey:BRANCH_REQUEST_KEY_URL_LINK_TYPE] integerValue]; diff --git a/src/ios/dependencies/Branch-SDK/BNCLocalization.h b/src/ios/dependencies/Branch-SDK/BNCLocalization.h index 49d5e7d0..fa65257d 100644 --- a/src/ios/dependencies/Branch-SDK/BNCLocalization.h +++ b/src/ios/dependencies/Branch-SDK/BNCLocalization.h @@ -6,7 +6,7 @@ // Copyright © 2017 Branch Metrics. All rights reserved. // -#import +@import Foundation; @interface BNCLocalization : NSObject @@ -15,8 +15,8 @@ + (NSDictionary*) languageDictionaries; - (NSString*) localizeString:(NSString*)string; -@property (copy) NSString* currentLanguage; -@property (strong, readonly) NSDictionary *currentLanguageDictionary; +@property (copy, atomic) NSString* currentLanguage; +@property (strong, atomic, readonly) NSDictionary *currentLanguageDictionary; @end #pragma mark Convenience Functions diff --git a/src/ios/dependencies/Branch-SDK/BNCLog.h b/src/ios/dependencies/Branch-SDK/BNCLog.h index b69a633c..841bf7d3 100644 --- a/src/ios/dependencies/Branch-SDK/BNCLog.h +++ b/src/ios/dependencies/Branch-SDK/BNCLog.h @@ -13,7 +13,7 @@ //-------------------------------------------------------------------------------------------------- -#import +@import Foundation; #import "BNCDebug.h" @@ -59,7 +59,7 @@ extern void BNCLogSetDisplayLevel(BNCLogLevel level); * @param level The log level to convert to a string. * @return Returns the string indicating the log level. */ -extern NSString *_Nonnull const BNCLogStringFromLogLevel(BNCLogLevel level); +extern NSString *_Nonnull BNCLogStringFromLogLevel(BNCLogLevel level); /*! * @param string A string indicating the log level. @@ -91,7 +91,7 @@ extern BNCLogClientInitializeFunctionPtr _Null_unspecified #pragma mark - Optional Log Output Handlers -///@info Pre-defined log message handlers -- +///@brief Pre-defined log message handlers -- typedef void (*BNCLogOutputFunctionPtr)(NSDate*_Nonnull timestamp, BNCLogLevel level, NSString*_Nullable message); diff --git a/src/ios/dependencies/Branch-SDK/BNCLog.m b/src/ios/dependencies/Branch-SDK/BNCLog.m index 4b4de8f6..8d691cff 100644 --- a/src/ios/dependencies/Branch-SDK/BNCLog.m +++ b/src/ios/dependencies/Branch-SDK/BNCLog.m @@ -13,7 +13,8 @@ //-------------------------------------------------------------------------------------------------- -#import "BNCLog.h" +#import "BNCLog.h" +#import // @import not available in Xcode 7 #define _countof(array) (sizeof(array)/sizeof(array[0])) @@ -490,7 +491,7 @@ void BNCLogSetDisplayLevel(BNCLogLevel level) { }); } -NSString*const bnc_logLevelStrings[] = { +static NSString*const bnc_logLevelStrings[] = { @"BNCLogLevelAll", @"BNCLogLevelBreakPoint", @"BNCLogLevelDebug", @@ -502,14 +503,14 @@ void BNCLogSetDisplayLevel(BNCLogLevel level) { @"BNCLogLevelMax" }; -NSString*const BNCLogStringFromLogLevel(BNCLogLevel level) { +NSString* BNCLogStringFromLogLevel(BNCLogLevel level) { level = MAX(MIN(level, BNCLogLevelMax), 0); return bnc_logLevelStrings[level]; } BNCLogLevel BNCLogLevelFromString(NSString*string) { if (!string) return BNCLogLevelNone; - for (NSInteger i = 0; i < _countof(bnc_logLevelStrings); ++i) { + for (NSUInteger i = 0; i < _countof(bnc_logLevelStrings); ++i) { if ([bnc_logLevelStrings[i] isEqualToString:string]) { return i; } @@ -522,7 +523,6 @@ BNCLogLevel BNCLogLevelFromString(NSString*string) { #pragma mark - Client Initialization Function -#include "stdatomic.h" static _Atomic(BNCLogClientInitializeFunctionPtr) bnc_LogClientInitializeFunctionPtr = (BNCLogClientInitializeFunctionPtr) 0; extern BNCLogClientInitializeFunctionPtr _Null_unspecified BNCLogSetClientInitializeFunction( diff --git a/src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.h b/src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.h index d82069d0..4d33fac0 100644 --- a/src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.h +++ b/src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.h @@ -6,7 +6,7 @@ // Copyright (c) 2014 Branch Metrics. All rights reserved. // -#import +@import Foundation; #define FILE_NAME [[NSString stringWithUTF8String:__FILE__] lastPathComponent] #define LINE_NUM __LINE__ @@ -39,9 +39,10 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void); @property (strong, nonatomic) NSMutableDictionary *savedAnalyticsData; @property (assign, nonatomic) NSInteger installRequestDelay; @property (strong, nonatomic) NSDictionary *appleSearchAdDetails; +@property (assign, nonatomic) BOOL appleSearchAdNeedsSend; @property (strong, nonatomic) NSString *lastSystemBuildVersion; @property (strong, nonatomic) NSString *browserUserAgentString; -@property (strong) NSString *branchAPIURL; +@property (strong, atomic) NSString *branchAPIURL; + (BNCPreferenceHelper *)preferenceHelper; diff --git a/src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.m b/src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.m index 6909f238..a8071318 100644 --- a/src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.m +++ b/src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.m @@ -99,7 +99,7 @@ + (BNCPreferenceHelper *)preferenceHelper { } - (id)init { - if (self = [super init]) { + if ((self = [super init])) { _timeout = DEFAULT_TIMEOUT; _retryCount = DEFAULT_RETRY_COUNT; _retryInterval = DEFAULT_RETRY_INTERVAL; @@ -121,24 +121,6 @@ + (BNCPreferenceHelper *)getInstance { return preferenceHelper; } - -/* - - This creates one global queue. Not so desirable. - -- (NSOperationQueue *)persistPrefsQueue { - static NSOperationQueue *persistPrefsQueue; - static dispatch_once_t persistOnceToken; - - dispatch_once(&persistOnceToken, ^{ - persistPrefsQueue = [[NSOperationQueue alloc] init]; - persistPrefsQueue.maxConcurrentOperationCount = 1; - }); - - return persistPrefsQueue; -} -*/ - - (NSOperationQueue *)persistPrefsQueue { @synchronized (self) { if (_persistPrefsQueue) @@ -150,8 +132,10 @@ - (NSOperationQueue *)persistPrefsQueue { } - (void) synchronize { - // Flushes preference queue to persistence. - [_persistPrefsQueue waitUntilAllOperationsAreFinished]; + @synchronized(self) { + // Flushes preference queue to persistence. + [_persistPrefsQueue waitUntilAllOperationsAreFinished]; + } } - (void) dealloc { @@ -419,6 +403,14 @@ - (NSDictionary*) appleSearchAdDetails { return [_appleSearchAdDetails isKindOfClass:[NSDictionary class]] ? _appleSearchAdDetails : nil; } +- (void) setAppleSearchAdNeedsSend:(BOOL)appleSearchAdNeedsSend { + [self writeBoolToDefaults:@"_appleSearchAdNeedsSend" value:appleSearchAdNeedsSend]; +} + +- (BOOL) appleSearchAdNeedsSend { + return [self readBoolFromDefaults:@"_appleSearchAdNeedsSend"]; +} + - (NSString*) lastSystemBuildVersion { if (!_lastSystemBuildVersion) { _lastSystemBuildVersion = [self readStringFromDefaults:@"_lastSystemBuildVersion"]; @@ -530,7 +522,7 @@ - (void)addInstrumentationDictionaryKey:(NSString *)key value:(NSString *)value - (void)clearInstrumentationDictionary { @synchronized (self) { NSArray *keys = [_instrumentationDictionary allKeys]; - for (int i = 0 ; i < [keys count]; i++) { + for (NSUInteger i = 0 ; i < [keys count]; i++) { [_instrumentationDictionary removeObjectForKey:keys[i]]; } } @@ -707,7 +699,7 @@ - (NSMutableDictionary *)persistenceDict { if (!error && data) persistenceDict = [NSKeyedUnarchiver unarchiveObjectWithData:data]; } - @catch (NSException *exception) { + @catch (NSException*) { BNCLogWarning(@"Failed to load preferences from storage."); } diff --git a/src/ios/dependencies/Branch-SDK/BNCStrongMatchHelper.h b/src/ios/dependencies/Branch-SDK/BNCStrongMatchHelper.h index f93cbf9b..4afc086a 100644 --- a/src/ios/dependencies/Branch-SDK/BNCStrongMatchHelper.h +++ b/src/ios/dependencies/Branch-SDK/BNCStrongMatchHelper.h @@ -6,10 +6,8 @@ // Copyright © 2015 Branch Metrics. All rights reserved. // - -#import -#import - +@import Foundation; +@import UIKit; @interface BNCStrongMatchHelper : NSObject diff --git a/src/ios/dependencies/Branch-SDK/BNCStrongMatchHelper.m b/src/ios/dependencies/Branch-SDK/BNCStrongMatchHelper.m index 31dbaa4a..a98a24fb 100644 --- a/src/ios/dependencies/Branch-SDK/BNCStrongMatchHelper.m +++ b/src/ios/dependencies/Branch-SDK/BNCStrongMatchHelper.m @@ -8,7 +8,7 @@ #import "BNCStrongMatchHelper.h" -#import +@import ObjectiveC.runtime; #import "BNCConfig.h" #import "BNCPreferenceHelper.h" #import "BNCSystemObserver.h" @@ -44,7 +44,7 @@ + (NSURL *)getUrlForCookieBasedMatchingWithBranchKey:(NSString *)branchKey #else // ------------------------------------------------------------------------------ iOS >= 9.0 -#import +@import SafariServices; #pragma mark - BNCMatchView @@ -192,9 +192,8 @@ + (NSURL *)getUrlForCookieBasedMatchingWithBranchKey:(NSString *)branchKey #pragma clang diagnostic pop } -+ (BOOL)cookiesAvailableInOS -{ - return [UIDevice currentDevice].systemVersion.floatValue < 11.0; ++ (BOOL)cookiesAvailableInOS { + return [UIDevice currentDevice].systemVersion.doubleValue < 11.0; } - (void)createStrongMatchWithBranchKey:(NSString *)branchKey { diff --git a/src/ios/dependencies/Branch-SDK/BNCSystemObserver.h b/src/ios/dependencies/Branch-SDK/BNCSystemObserver.h index ec48f7ce..2fbbdd0d 100644 --- a/src/ios/dependencies/Branch-SDK/BNCSystemObserver.h +++ b/src/ios/dependencies/Branch-SDK/BNCSystemObserver.h @@ -6,7 +6,7 @@ // Copyright (c) 2014 Branch Metrics. All rights reserved. // -#import +@import Foundation; typedef NS_ENUM(NSInteger, BNCUpdateState) { BNCUpdateStateInstall = 0, // App was recently installed. @@ -16,7 +16,9 @@ typedef NS_ENUM(NSInteger, BNCUpdateState) { @interface BNCSystemObserver : NSObject -+ (NSString *)getUniqueHardwareId:(BOOL *)isReal isDebug:(BOOL)debug andType:(NSString **)type; ++ (NSString *)getUniqueHardwareId:(BOOL *)isReal + isDebug:(BOOL)debug + andType:(NSString *__autoreleasing*)type; + (NSString *)getVendorId; + (NSString *)getDefaultUriScheme; + (NSString *)getAppVersion; diff --git a/src/ios/dependencies/Branch-SDK/BNCSystemObserver.m b/src/ios/dependencies/Branch-SDK/BNCSystemObserver.m index 2c72958a..18a90741 100644 --- a/src/ios/dependencies/Branch-SDK/BNCSystemObserver.m +++ b/src/ios/dependencies/Branch-SDK/BNCSystemObserver.m @@ -6,18 +6,18 @@ // Copyright (c) 2014 Branch Metrics. All rights reserved. // -#import -#include +@import UIKit; +@import SystemConfiguration; +@import Darwin.POSIX.sys.utsname; #import "BNCPreferenceHelper.h" #import "BNCSystemObserver.h" -#import -#import -#import #import "BNCLog.h" @implementation BNCSystemObserver -+ (NSString *)getUniqueHardwareId:(BOOL *)isReal isDebug:(BOOL)debug andType:(NSString **)type { ++ (NSString *)getUniqueHardwareId:(BOOL *)isReal + isDebug:(BOOL)debug + andType:(NSString *__autoreleasing*)type { NSString *uid = nil; *isReal = YES; @@ -135,14 +135,14 @@ + (NSString *)getOSVersion { + (NSNumber *)getScreenWidth { UIScreen *mainScreen = [UIScreen mainScreen]; - float scaleFactor = mainScreen.scale; + CGFloat scaleFactor = mainScreen.scale; CGFloat width = mainScreen.bounds.size.width * scaleFactor; return [NSNumber numberWithInteger:(NSInteger)width]; } + (NSNumber *)getScreenHeight { UIScreen *mainScreen = [UIScreen mainScreen]; - float scaleFactor = mainScreen.scale; + CGFloat scaleFactor = mainScreen.scale; CGFloat height = mainScreen.bounds.size.height * scaleFactor; return [NSNumber numberWithInteger:(NSInteger)height]; } diff --git a/src/ios/dependencies/Branch-SDK/BNCXcode7Support.h b/src/ios/dependencies/Branch-SDK/BNCXcode7Support.h index 0c2aca00..fa5f4042 100644 --- a/src/ios/dependencies/Branch-SDK/BNCXcode7Support.h +++ b/src/ios/dependencies/Branch-SDK/BNCXcode7Support.h @@ -6,13 +6,10 @@ // Copyright © 2016 Branch Metrics. All rights reserved. // - #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < 100000 #warning Warning: Compiling with Xcode 7 support - -#import - +@import Foundation; @interface NSLocale (BranchXcode7Support) - (NSString*) countryCode; diff --git a/src/ios/dependencies/Branch-SDK/Branch.h b/src/ios/dependencies/Branch-SDK/Branch.h index fb00f2cf..00635b63 100644 --- a/src/ios/dependencies/Branch-SDK/Branch.h +++ b/src/ios/dependencies/Branch-SDK/Branch.h @@ -5,8 +5,8 @@ // Created by Alex Austin on 6/5/14. // Copyright (c) 2014 Branch Metrics. All rights reserved. // -#import -#import +@import Foundation; +@import UIKit; #import "BNCCallbacks.h" #import "BNCCommerceEvent.h" #import "BNCConfig.h" @@ -313,7 +313,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) { @param stage The stage used for the generated link, typically used to indicate what part of a funnel the user is in. @param tags An array of tag strings to be associated with the link. @param alias The alias for a link. - @params delegate A delegate allowing you to override any of the parameters provided here based on the user-selected channel + @param delegate A delegate allowing you to override any of the parameters provided here based on the user-selected channel @warning This can fail if the alias is already taken. */ + (BranchActivityItemProvider *)getBranchActivityItemWithParams:(NSDictionary *)params feature:(NSString *)feature stage:(NSString *)stage tags:(NSArray *)tags alias:(NSString *)alias delegate:(id )delegate; diff --git a/src/ios/dependencies/Branch-SDK/Branch.m b/src/ios/dependencies/Branch-SDK/Branch.m index f7607edf..5d8ae0bc 100644 --- a/src/ios/dependencies/Branch-SDK/Branch.m +++ b/src/ios/dependencies/Branch-SDK/Branch.m @@ -69,7 +69,7 @@ NSString * const BNCShareInitiatedEvent = @"Share Started"; NSString * const BNCShareCompletedEvent = @"Share Completed"; -NSString * const BNCLogLevelKey = @"io.branch.sdk.BNCLogLevel"; +static NSString * const BNCLogLevelKey = @"io.branch.sdk.BNCLogLevel"; #pragma mark - Load Categories @@ -319,8 +319,9 @@ + (void) setBranchKey:(NSString*)branchKey { return; } if (![branchKey isKindOfClass:[NSString class]]) { + NSString *typeName = (branchKey) ? NSStringFromClass(branchKey.class) : @""; [NSException raise:NSInternalInconsistencyException - format:@"Invalid Branch key of type '%@'.", NSStringFromClass(branchKey.class)]; + format:@"Invalid Branch key of type '%@'.", typeName]; return; } @@ -617,10 +618,12 @@ - (BOOL)handleSchemeDeepLink:(NSURL*)url fromSelf:(BOOL)isFromSelf { BOOL handled = NO; if (url && ![url isEqual:[NSNull null]]) { + NSString *urlScheme = [url scheme]; + // save the incoming url in the preferenceHelper in the externalIntentURI field if ([self.whiteListedSchemeList count]) { for (NSString *scheme in self.whiteListedSchemeList) { - if ([scheme isEqualToString:[url scheme]]) { + if (urlScheme && [scheme isEqualToString:urlScheme]) { self.preferenceHelper.externalIntentURI = [url absoluteString]; break; } @@ -805,20 +808,22 @@ - (BOOL)checkAppleSearchAdsAttribution { ^ void(NSDictionary *__nullable attrDetails, NSError *__nullable error) { self.asyncRequestCount--; - if (attrDetails.count) { - self.preferenceHelper.appleSearchAdDetails = attrDetails; - } - else if (self.searchAdsDebugMode) { + // If searchAdsDebugMode is on then force the result to a set value for testing: + if (self.searchAdsDebugMode) { + // Round down to one day for testing. + NSTimeInterval const kOneHour = (60.0*60.0*1.0); + NSTimeInterval t = trunc([[NSDate date] timeIntervalSince1970] / kOneHour) * kOneHour; + NSDate *date = [NSDate dateWithTimeIntervalSince1970:t]; - NSDictionary *debugSearchAd = @{ + attrDetails = @{ @"Version3.1": @{ @"iad-adgroup-id": @1234567890, @"iad-adgroup-name": @"AdGroupName", @"iad-attribution": (id)kCFBooleanTrue, @"iad-campaign-id": @1234567890, @"iad-campaign-name": @"CampaignName", - @"iad-click-date": [NSDate date], - @"iad-conversion-date": [NSDate date], + @"iad-click-date": date, + @"iad-conversion-date": date, @"iad-creative-id": @1234567890, @"iad-creative-name": @"CreativeName", @"iad-keyword": @"Keyword", @@ -827,11 +832,17 @@ - (BOOL)checkAppleSearchAdsAttribution { @"iad-org-name": @"OrgName" } }; + } - self.preferenceHelper.appleSearchAdDetails = debugSearchAd; + if (attrDetails == nil) attrDetails = @{}; + if (self.preferenceHelper.appleSearchAdDetails == nil) + self.preferenceHelper.appleSearchAdDetails = @{}; + if (![self.preferenceHelper.appleSearchAdDetails isEqualToDictionary:attrDetails]) { + self.preferenceHelper.appleSearchAdDetails = attrDetails; + self.preferenceHelper.appleSearchAdNeedsSend = YES; } - // if there's another async attribution check in flight, don't continue with init + // If there's another async attribution check in flight, don't continue with init if (self.asyncRequestCount > 0) { return; } self.preferenceHelper.shouldWaitForInit = NO; @@ -841,13 +852,14 @@ - (BOOL)checkAppleSearchAdsAttribution { }); }; - ((void (*)(id, SEL, void (^ __nullable)(NSDictionary *__nullable attrDetails, NSError * __nullable error)))[sharedClientInstance methodForSelector:requestAttribution])(sharedClientInstance, requestAttribution, completionBlock); + ((void (*)(id, SEL, void (^ __nullable)(NSDictionary *__nullable attrDetails, NSError * __nullable error))) + [sharedClientInstance methodForSelector:requestAttribution]) + (sharedClientInstance, requestAttribution, completionBlock); return YES; } - -# pragma mark - Facebook App Link check +#pragma mark - Facebook App Link Check - (void)registerFacebookDeepLinkingClass:(id)FBSDKAppLinkUtility { self.FBSDKAppLinkUtility = FBSDKAppLinkUtility; diff --git a/src/ios/dependencies/Branch-SDK/BranchActivityItemProvider.h b/src/ios/dependencies/Branch-SDK/BranchActivityItemProvider.h index 2eeaf7e2..db72025a 100644 --- a/src/ios/dependencies/Branch-SDK/BranchActivityItemProvider.h +++ b/src/ios/dependencies/Branch-SDK/BranchActivityItemProvider.h @@ -6,7 +6,7 @@ // Copyright (c) 2015 Branch Metrics. All rights reserved. // -#import +@import UIKit; /** The `BranchActivityItemProviderDelegate` allows you to customize the link parameters based on the channel chosen by the user. diff --git a/src/ios/dependencies/Branch-SDK/BranchActivityItemProvider.m b/src/ios/dependencies/Branch-SDK/BranchActivityItemProvider.m index 950827ac..8e81ec11 100644 --- a/src/ios/dependencies/Branch-SDK/BranchActivityItemProvider.m +++ b/src/ios/dependencies/Branch-SDK/BranchActivityItemProvider.m @@ -27,30 +27,70 @@ @interface BranchActivityItemProvider () @implementation BranchActivityItemProvider -- (id)initWithParams:(NSDictionary *)params andTags:(NSArray *)tags andFeature:(NSString *)feature andStage:(NSString *)stage andAlias:(NSString *)alias { +- (id)initWithParams:(NSDictionary *)params + andTags:(NSArray *)tags + andFeature:(NSString *)feature + andStage:(NSString *)stage + andAlias:(NSString *)alias { return [self initWithParams:params tags:tags feature:feature stage:stage campaign:nil alias:alias delegate:nil]; } -- (id)initWithParams:(NSDictionary *)params tags:(NSArray *)tags feature:(NSString *)feature stage:(NSString *)stage campaign:(NSString *)campaign alias:(NSString *)alias delegate:(id )delegate { - NSString *url = [[Branch getInstance] getLongURLWithParams:params andChannel:nil andTags:tags andFeature:feature andStage:stage andAlias:alias]; - - if (self = [super initWithPlaceholderItem:[NSURL URLWithString:url]]) { - _params = params; - _tags = tags; - _feature = feature; - _stage = stage; - _campaign = campaign; - _alias = alias; - _userAgentString = [BNCDeviceInfo userAgentString]; - _delegate = delegate; +- (id)initWithParams:(NSDictionary *)params + tags:(NSArray *)tags + feature:(NSString *)feature + stage:(NSString *)stage + campaign:(NSString *)campaign + alias:(NSString *)alias + delegate:(id )delegate { + + NSString *url = + [[Branch getInstance] + getLongURLWithParams:params + andChannel:nil + andTags:tags + andFeature:feature + andStage:stage + andAlias:alias]; + + if (self.returnURL) { + if ((self = [super initWithPlaceholderItem:[NSURL URLWithString:url]])) { + _params = params; + _tags = tags; + _feature = feature; + _stage = stage; + _campaign = campaign; + _alias = alias; + _userAgentString = [BNCDeviceInfo userAgentString]; + _delegate = delegate; + } + } else { + if ((self = [super initWithPlaceholderItem:url])) { + _params = params; + _tags = tags; + _feature = feature; + _stage = stage; + _campaign = campaign; + _alias = alias; + _userAgentString = [BNCDeviceInfo userAgentString]; + _delegate = delegate; + } } - return self; } +- (BOOL) returnURL { + BOOL returnURL = YES; + if ([UIDevice currentDevice].systemVersion.doubleValue >= 11.0 && + [self.activityType isEqualToString:UIActivityTypeCopyToPasteboard]) { + returnURL = NO; + } + return returnURL; +} + - (id)item { NSString *channel = [BranchActivityItemProvider humanReadableChannelWithActivityType:self.activityType]; - + + // Allow for overrides specific to channel NSDictionary *params = [self paramsForChannel:channel]; NSArray *tags = [self tagsForChannel:channel]; @@ -68,8 +108,8 @@ - (id)item { // existing list, telling the backend to ignore the first click NSArray *scrapers = @[@"Facebook", @"Twitter", @"Slack", @"Apple Notes"]; for (NSString *scraper in scrapers) { - if ([channel isEqualToString:scraper]) - return [NSURL URLWithString:[[Branch getInstance] + if ([channel isEqualToString:scraper]) { + NSURL *URL = [NSURL URLWithString:[[Branch getInstance] getShortURLWithParams:params andTags:tags andChannel:channel @@ -79,6 +119,8 @@ - (id)item { andAlias:alias ignoreUAString:self.userAgentString forceLinkCreation:YES]]; + return (self.returnURL) ? URL : URL.absoluteString; + } } // Wrap the link in HTML content @@ -109,17 +151,18 @@ - (id)item { [params objectForKey:BRANCH_LINK_DATA_KEY_EMAIL_HTML_FOOTER]]; } - return [NSURL URLWithString:[[Branch getInstance] - getShortURLWithParams:params - andTags:tags - andChannel:channel - andFeature:feature - andStage:stage - andCampaign:campaign - andAlias:alias - ignoreUAString:nil - forceLinkCreation:YES]]; - + NSURL *URL = + [NSURL URLWithString:[[Branch getInstance] + getShortURLWithParams:params + andTags:tags + andChannel:channel + andFeature:feature + andStage:stage + andCampaign:campaign + andAlias:alias + ignoreUAString:nil + forceLinkCreation:YES]]; + return (self.returnURL) ? URL : URL.absoluteString; } #pragma mark - Internals @@ -160,28 +203,39 @@ + (NSString *)humanReadableChannelWithActivityType:(NSString *)activityString { } - (NSDictionary *)paramsForChannel:(NSString *)channel { - return ([self.delegate respondsToSelector:@selector(activityItemParamsForChannel:)]) ? [self.delegate activityItemParamsForChannel:channel] : self.params; + return ([self.delegate respondsToSelector:@selector(activityItemParamsForChannel:)]) + ? [self.delegate activityItemParamsForChannel:channel] + : self.params; } - (NSArray *)tagsForChannel:(NSString *)channel { - return ([self.delegate respondsToSelector:@selector(activityItemTagsForChannel:)]) ? [self.delegate activityItemTagsForChannel:channel] : self.tags; + return ([self.delegate respondsToSelector:@selector(activityItemTagsForChannel:)]) + ? [self.delegate activityItemTagsForChannel:channel] + : self.tags; } - (NSString *)featureForChannel:(NSString *)channel { - return ([self.delegate respondsToSelector:@selector(activityItemFeatureForChannel:)]) ? [self.delegate activityItemFeatureForChannel:channel] : self.feature; + return ([self.delegate respondsToSelector:@selector(activityItemFeatureForChannel:)]) + ? [self.delegate activityItemFeatureForChannel:channel] + : self.feature; } - (NSString *)stageForChannel:(NSString *)channel { - return ([self.delegate respondsToSelector:@selector(activityItemStageForChannel:)]) ? [self.delegate activityItemStageForChannel:channel] : self.stage; + return ([self.delegate respondsToSelector:@selector(activityItemStageForChannel:)]) + ? [self.delegate activityItemStageForChannel:channel] + : self.stage; } - (NSString *)campaignForChannel:(NSString *)channel { - return ([self.delegate respondsToSelector:@selector(activityItemCampaignForChannel:)]) ? [self.delegate activityItemCampaignForChannel:channel] : self.campaign; + return ([self.delegate respondsToSelector:@selector(activityItemCampaignForChannel:)]) + ? [self.delegate activityItemCampaignForChannel:channel] + : self.campaign; } - - (NSString *)aliasForChannel:(NSString *)channel { - return ([self.delegate respondsToSelector:@selector(activityItemAliasForChannel:)]) ? [self.delegate activityItemAliasForChannel:channel] : self.alias; + return ([self.delegate respondsToSelector:@selector(activityItemAliasForChannel:)]) + ? [self.delegate activityItemAliasForChannel:channel] + : self.alias; } @end diff --git a/src/ios/dependencies/Branch-SDK/BranchCSSearchableItemAttributeSet.h b/src/ios/dependencies/Branch-SDK/BranchCSSearchableItemAttributeSet.h index 2bcfa416..292a2795 100644 --- a/src/ios/dependencies/Branch-SDK/BranchCSSearchableItemAttributeSet.h +++ b/src/ios/dependencies/Branch-SDK/BranchCSSearchableItemAttributeSet.h @@ -8,7 +8,7 @@ #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000 -#import +@import CoreSpotlight; #import "Branch.h" @interface BranchCSSearchableItemAttributeSet : CSSearchableItemAttributeSet @@ -26,4 +26,4 @@ @end -#endif \ No newline at end of file +#endif diff --git a/src/ios/dependencies/Branch-SDK/BranchCSSearchableItemAttributeSet.m b/src/ios/dependencies/Branch-SDK/BranchCSSearchableItemAttributeSet.m index e03bca50..de115f65 100644 --- a/src/ios/dependencies/Branch-SDK/BranchCSSearchableItemAttributeSet.m +++ b/src/ios/dependencies/Branch-SDK/BranchCSSearchableItemAttributeSet.m @@ -9,10 +9,11 @@ #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000 #import "BranchCSSearchableItemAttributeSet.h" +@import MobileCoreServices; #import "BNCSystemObserver.h" #import "BNCError.h" #import "BranchConstants.h" -#import + #import "BNCLog.h" #ifndef kUTTypeGeneric diff --git a/src/ios/dependencies/Branch-SDK/BranchConstants.h b/src/ios/dependencies/Branch-SDK/BranchConstants.h index 5ec9175f..039ecfbf 100644 --- a/src/ios/dependencies/Branch-SDK/BranchConstants.h +++ b/src/ios/dependencies/Branch-SDK/BranchConstants.h @@ -6,7 +6,7 @@ // Copyright (c) 2015 Branch Metrics. All rights reserved. // -#import +@import Foundation; extern NSString * const BRANCH_REQUEST_KEY_BRANCH_IDENTITY; extern NSString * const BRANCH_REQUEST_KEY_DEVELOPER_IDENTITY; diff --git a/src/ios/dependencies/Branch-SDK/BranchContentDiscoverer.h b/src/ios/dependencies/Branch-SDK/BranchContentDiscoverer.h index 21071099..dd87e48e 100644 --- a/src/ios/dependencies/Branch-SDK/BranchContentDiscoverer.h +++ b/src/ios/dependencies/Branch-SDK/BranchContentDiscoverer.h @@ -7,7 +7,7 @@ // -#import +@import UIKit; #import "BranchContentDiscoveryManifest.h" diff --git a/src/ios/dependencies/Branch-SDK/BranchContentDiscoverer.m b/src/ios/dependencies/Branch-SDK/BranchContentDiscoverer.m index 27cd7a54..89db1552 100644 --- a/src/ios/dependencies/Branch-SDK/BranchContentDiscoverer.m +++ b/src/ios/dependencies/Branch-SDK/BranchContentDiscoverer.m @@ -7,14 +7,14 @@ // -#import +@import Foundation; +@import UIKit; +#import #import "BranchContentDiscoverer.h" #import "BranchContentDiscoveryManifest.h" #import "BranchContentPathProperties.h" #import "BNCPreferenceHelper.h" #import "BranchConstants.h" -#import -#import #import "BNCEncodingUtils.h" #import "BNCLog.h" diff --git a/src/ios/dependencies/Branch-SDK/BranchContentDiscoveryManifest.h b/src/ios/dependencies/Branch-SDK/BranchContentDiscoveryManifest.h index 50948879..d1eeb615 100644 --- a/src/ios/dependencies/Branch-SDK/BranchContentDiscoveryManifest.h +++ b/src/ios/dependencies/Branch-SDK/BranchContentDiscoveryManifest.h @@ -6,7 +6,7 @@ // Copyright © 2016 Branch Metrics. All rights reserved. // #import "BranchContentPathProperties.h" -#import +@import UIKit; #ifndef ContentDiscoverManifest_h #define ContentDiscoverManifest_h @@ -28,4 +28,4 @@ - (BranchContentPathProperties *)getContentPathProperties:(UIViewController *)viewController; - (void)onBranchInitialised:(NSDictionary *)branchInitDict withUrl:(NSString *)referredUrl; -@end \ No newline at end of file +@end diff --git a/src/ios/dependencies/Branch-SDK/BranchContentDiscoveryManifest.m b/src/ios/dependencies/Branch-SDK/BranchContentDiscoveryManifest.m index 7e755752..30e14571 100644 --- a/src/ios/dependencies/Branch-SDK/BranchContentDiscoveryManifest.m +++ b/src/ios/dependencies/Branch-SDK/BranchContentDiscoveryManifest.m @@ -7,11 +7,11 @@ // -#import +@import Foundation; +@import UIKit; #import "BranchContentDiscoveryManifest.h" #import "BNCPreferenceHelper.h" #import "BranchContentPathProperties.h" -#import #import "BranchConstants.h" diff --git a/src/ios/dependencies/Branch-SDK/BranchContentPathProperties.m b/src/ios/dependencies/Branch-SDK/BranchContentPathProperties.m index 1f36ffd0..ff1e7327 100644 --- a/src/ios/dependencies/Branch-SDK/BranchContentPathProperties.m +++ b/src/ios/dependencies/Branch-SDK/BranchContentPathProperties.m @@ -6,7 +6,7 @@ // Copyright © 2016 Branch Metrics. All rights reserved. // -#import +@import Foundation; #import "BranchContentPathProperties.h" #import "BranchConstants.h" @@ -36,4 +36,4 @@ - (BOOL)isClearText { return _isClearText; } -@end \ No newline at end of file +@end diff --git a/src/ios/dependencies/Branch-SDK/BranchDeepLinkingController.h b/src/ios/dependencies/Branch-SDK/BranchDeepLinkingController.h index 07f99e18..1e3cfc8e 100644 --- a/src/ios/dependencies/Branch-SDK/BranchDeepLinkingController.h +++ b/src/ios/dependencies/Branch-SDK/BranchDeepLinkingController.h @@ -5,8 +5,10 @@ // Created by Graham Mueller on 6/18/15. // Copyright (c) 2015 Branch Metrics. All rights reserved. // -#import -#import + +@import Foundation; +@import UIKit; + @protocol BranchDeepLinkingControllerCompletionDelegate - (void)deepLinkingControllerCompleted __attribute__((deprecated(("This API is deprecated. Instead, use deepLinkingControllerCompletedFrom: viewController"))));; diff --git a/src/ios/dependencies/Branch-SDK/BranchLinkProperties.h b/src/ios/dependencies/Branch-SDK/BranchLinkProperties.h index c4db6ba3..aff1a3d5 100644 --- a/src/ios/dependencies/Branch-SDK/BranchLinkProperties.h +++ b/src/ios/dependencies/Branch-SDK/BranchLinkProperties.h @@ -6,7 +6,7 @@ // Copyright © 2015 Branch Metrics. All rights reserved. // -#import +@import Foundation; @interface BranchLinkProperties : NSObject diff --git a/src/ios/dependencies/Branch-SDK/BranchShareLink.h b/src/ios/dependencies/Branch-SDK/BranchShareLink.h index 29977044..f7ae653d 100644 --- a/src/ios/dependencies/Branch-SDK/BranchShareLink.h +++ b/src/ios/dependencies/Branch-SDK/BranchShareLink.h @@ -6,7 +6,7 @@ // Copyright © 2017 Branch Metrics. All rights reserved. // -#import +@import Foundation; #import "BranchUniversalObject.h" @class BranchShareLink; @@ -61,7 +61,7 @@ parameters can be changed depending on the activity that the user selects. /** Creates a BranchShareLink object. -@oaram universalObject The Branch Universal Object the will be shared. +@param universalObject The Branch Universal Object the will be shared. @param linkProperties The link properties that the link will have. */ - (instancetype _Nullable) initWithUniversalObject:(BranchUniversalObject*_Nonnull)universalObject @@ -75,7 +75,7 @@ Creates a BranchShareLink object. /** Presents a UIActivityViewController that shares the Branch link. -@oaram viewController The parent view controller from which to present the the activity sheet. +@param viewController The parent view controller from which to present the the activity sheet. @param anchor The anchor point for the activity sheet. Used for iPad form factors. */ - (void) presentActivityViewControllerFromViewController:(UIViewController*_Nullable)viewController diff --git a/src/ios/dependencies/Branch-SDK/BranchShareLink.m b/src/ios/dependencies/Branch-SDK/BranchShareLink.m index a83c8d44..b6dfb2b0 100644 --- a/src/ios/dependencies/Branch-SDK/BranchShareLink.m +++ b/src/ios/dependencies/Branch-SDK/BranchShareLink.m @@ -128,7 +128,10 @@ - (void) shareDidComplete:(BOOL)completed activityError:(NSError*)error { andStage:self.linkProperties.stage andAlias:self.linkProperties.alias]; self.shareURL = [[NSURL alloc] initWithString:URLString]; - item = [[BranchShareActivityItem alloc] initWithPlaceholderItem:self.shareURL]; + if (self.returnURL) + item = [[BranchShareActivityItem alloc] initWithPlaceholderItem:self.shareURL]; + else + item = [[BranchShareActivityItem alloc] initWithPlaceholderItem:self.shareURL.absoluteString]; item.itemType = BranchShareActivityItemTypeBranchURL; item.parent = self; [items addObject:item]; @@ -183,7 +186,7 @@ - (void) presentActivityViewControllerFromViewController:(UIViewController*_Null setValue:self.linkProperties.controlParams[BRANCH_LINK_DATA_KEY_EMAIL_SUBJECT] forKey:@"subject"]; } - @catch (NSException *exception) { + @catch (NSException*) { BNCLogWarning(@"Unable to setValue 'emailSubject' forKey 'subject' on UIActivityViewController."); } } @@ -258,7 +261,16 @@ - (id) shareObjectForItem:(BranchShareActivityItem*)activityItem ignoreUAString:userAgentString forceLinkCreation:YES]; self.shareURL = [NSURL URLWithString:URLString]; - return self.shareURL; + return (self.returnURL) ? self.shareURL :self.shareURL.absoluteString; +} + +- (BOOL) returnURL { + BOOL returnURL = YES; + if ([UIDevice currentDevice].systemVersion.doubleValue >= 11.0 && + [self.activityType isEqualToString:UIActivityTypeCopyToPasteboard]) { + returnURL = NO; + } + return returnURL; } @end diff --git a/src/ios/dependencies/Branch-SDK/BranchUniversalObject.h b/src/ios/dependencies/Branch-SDK/BranchUniversalObject.h index 987d1023..78384cc7 100644 --- a/src/ios/dependencies/Branch-SDK/BranchUniversalObject.h +++ b/src/ios/dependencies/Branch-SDK/BranchUniversalObject.h @@ -6,7 +6,7 @@ // Copyright © 2015 Branch Metrics. All rights reserved. // -#import +@import Foundation; #import "Branch.h" @class BranchLinkProperties; @@ -21,7 +21,7 @@ typedef NS_ENUM(NSInteger, ContentIndexMode) { @interface BranchUniversalObject : NSObject -@property (nonatomic, strong, nonnull) NSString *canonicalIdentifier; +@property (nonatomic, strong, nonnull) NSString *canonicalIdentifier; @property (nonatomic, strong, nullable) NSString *canonicalUrl; @property (nonatomic, strong, nullable) NSString *title; @property (nonatomic, strong, nullable) NSString *contentDescription; diff --git a/src/ios/dependencies/Branch-SDK/BranchView.h b/src/ios/dependencies/Branch-SDK/BranchView.h index a85f1f21..7bd4f56b 100644 --- a/src/ios/dependencies/Branch-SDK/BranchView.h +++ b/src/ios/dependencies/Branch-SDK/BranchView.h @@ -6,8 +6,8 @@ // Copyright © 2016 Branch Metrics. All rights reserved. // -#import -#import +@import Foundation; +@import UIKit; @interface BranchView : NSObject //-------- properties-------------------// diff --git a/src/ios/dependencies/Branch-SDK/BranchView.m b/src/ios/dependencies/Branch-SDK/BranchView.m index 49dda857..29f22abb 100644 --- a/src/ios/dependencies/Branch-SDK/BranchView.m +++ b/src/ios/dependencies/Branch-SDK/BranchView.m @@ -6,11 +6,11 @@ // Copyright © 2016 Branch Metrics. All rights reserved. // -#import +@import Foundation; #import "BranchView.h" #import "BNCPreferenceHelper.h" -NSInteger const BRANCH_VIEW_USAGE_UNLIMITED = -1; +NSInteger const BRANCH_VIEW_USAGE_UNLIMITED = -1; NSString * const BRANCH_VIEW_ID = @"id"; NSString * const BRANCH_VIEW_ACTION = @"action"; NSString * const BRANCH_VIEW_NUM_USE = @"number_of_use"; diff --git a/src/ios/dependencies/Branch-SDK/BranchViewHandler.m b/src/ios/dependencies/Branch-SDK/BranchViewHandler.m index 734cf41b..c40fdbb9 100644 --- a/src/ios/dependencies/Branch-SDK/BranchViewHandler.m +++ b/src/ios/dependencies/Branch-SDK/BranchViewHandler.m @@ -6,8 +6,8 @@ // Copyright © 2016 Branch Metrics. All rights reserved. // -#import -#import +@import Foundation; +@import UIKit; #import "BranchViewHandler.h" #import "Branch.h" #import "BranchView.h" diff --git a/src/ios/dependencies/Branch-SDK/NSMutableDictionary+Branch.h b/src/ios/dependencies/Branch-SDK/NSMutableDictionary+Branch.h index 1a36dfde..a19909f2 100644 --- a/src/ios/dependencies/Branch-SDK/NSMutableDictionary+Branch.h +++ b/src/ios/dependencies/Branch-SDK/NSMutableDictionary+Branch.h @@ -6,13 +6,10 @@ // Copyright © 2017 Branch Metrics. All rights reserved. // - -#import - +@import Foundation; void BNCForceNSMutableDictionaryCategoryToLoad(void) __attribute__((constructor)); - @interface NSMutableDictionary (Branch) - (void) bnc_safeSetObject:(id)anObject forKey:(id)aKey; diff --git a/src/ios/dependencies/Branch-SDK/NSString+Branch.h b/src/ios/dependencies/Branch-SDK/NSString+Branch.h index 764fb31f..6a2ab50e 100644 --- a/src/ios/dependencies/Branch-SDK/NSString+Branch.h +++ b/src/ios/dependencies/Branch-SDK/NSString+Branch.h @@ -12,9 +12,7 @@ // //-------------------------------------------------------------------------------------------------- - -#import - +@import Foundation; @interface NSString (Branch) diff --git a/src/ios/dependencies/Branch-SDK/NSString+Branch.m b/src/ios/dependencies/Branch-SDK/NSString+Branch.m index d7ecdabf..a7581ffd 100644 --- a/src/ios/dependencies/Branch-SDK/NSString+Branch.m +++ b/src/ios/dependencies/Branch-SDK/NSString+Branch.m @@ -28,7 +28,7 @@ - (BOOL) bnc_isEqualToMaskedString:(NSString*_Nullable)string { // NSLog(@"bnc_isEqualToMaskedString self/string:\n%@\n%@.", self, string); if (!string) return NO; if (self.length != string.length) return NO; - for (NSInteger idx = 0; idx < self.length; idx++) { + for (NSUInteger idx = 0; idx < self.length; idx++) { unichar p = [self characterAtIndex:idx]; unichar q = [string characterAtIndex:idx]; if (q != '*' && p != q) return NO; @@ -46,8 +46,7 @@ - (NSString*_Nonnull) bnc_stringTruncatedAtNull { } - (BOOL) bnc_containsString:(NSString*_Nullable)string { - if (!string) return NO; - return ([self rangeOfString:string].location != NSNotFound); + return (string && [self rangeOfString:(NSString*_Nonnull)string].location != NSNotFound); } @end diff --git a/src/ios/dependencies/Branch-SDK/Networking/BNCNetworkService.h b/src/ios/dependencies/Branch-SDK/Networking/BNCNetworkService.h index e824a2b2..d199cd56 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/BNCNetworkService.h +++ b/src/ios/dependencies/Branch-SDK/Networking/BNCNetworkService.h @@ -6,7 +6,7 @@ // Copyright © 2017 Branch Metrics. All rights reserved. // -#import +@import Foundation; #import "BNCNetworkServiceProtocol.h" /** diff --git a/src/ios/dependencies/Branch-SDK/Networking/BNCNetworkService.m b/src/ios/dependencies/Branch-SDK/Networking/BNCNetworkService.m index 0cde86d7..6317f74d 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/BNCNetworkService.m +++ b/src/ios/dependencies/Branch-SDK/Networking/BNCNetworkService.m @@ -37,8 +37,8 @@ @interface BNCNetworkService () - (void) startOperation:(BNCNetworkOperation*)operation; -@property (strong, readonly) NSURLSession *session; -@property (strong) NSOperationQueue *sessionQueue; +@property (strong, atomic, readonly) NSURLSession *session; +@property (strong, atomic) NSOperationQueue *sessionQueue; @end #pragma mark - BNCNetworkOperation diff --git a/src/ios/dependencies/Branch-SDK/Networking/BNCNetworkServiceProtocol.h b/src/ios/dependencies/Branch-SDK/Networking/BNCNetworkServiceProtocol.h index 1841021e..44c8a3e4 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/BNCNetworkServiceProtocol.h +++ b/src/ios/dependencies/Branch-SDK/Networking/BNCNetworkServiceProtocol.h @@ -6,7 +6,7 @@ // Copyright © 2017 Branch Metrics. All rights reserved. // -#import +@import Foundation; #pragma mark BNCNetworkOperationProtocol diff --git a/src/ios/dependencies/Branch-SDK/Networking/BNCServerInterface.h b/src/ios/dependencies/Branch-SDK/Networking/BNCServerInterface.h index 26c6175c..6d508d30 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/BNCServerInterface.h +++ b/src/ios/dependencies/Branch-SDK/Networking/BNCServerInterface.h @@ -6,7 +6,7 @@ // Copyright (c) 2014 Branch Metrics. All rights reserved. // -#import +@import Foundation; #import "BNCServerResponse.h" #import "BNCPreferenceHelper.h" #import "BNCNetworkServiceProtocol.h" diff --git a/src/ios/dependencies/Branch-SDK/Networking/BNCServerInterface.m b/src/ios/dependencies/Branch-SDK/Networking/BNCServerInterface.m index b9710bc9..b40ee91c 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/BNCServerInterface.m +++ b/src/ios/dependencies/Branch-SDK/Networking/BNCServerInterface.m @@ -779,6 +779,7 @@ - (void)updateDeviceInfoToMutableDictionary:(NSMutableDictionary *)dict { [self safeSetValue:deviceInfo.browserUserAgent forKey:@"user_agent" onDict:dict]; [self safeSetValue:deviceInfo.country forKey:@"country" onDict:dict]; [self safeSetValue:deviceInfo.language forKey:@"language" onDict:dict]; + dict[@"local_ip"] = deviceInfo.localIPAddress; dict[BRANCH_REQUEST_KEY_AD_TRACKING_ENABLED] = @(deviceInfo.isAdTrackingEnabled); } diff --git a/src/ios/dependencies/Branch-SDK/Networking/BNCServerRequest.h b/src/ios/dependencies/Branch-SDK/Networking/BNCServerRequest.h index 6a6ab51b..18f529c4 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/BNCServerRequest.h +++ b/src/ios/dependencies/Branch-SDK/Networking/BNCServerRequest.h @@ -6,7 +6,7 @@ // Copyright (c) 2014 Branch Metrics. All rights reserved. // -#import +@import Foundation; #import "BNCServerInterface.h" @interface BNCServerRequest : NSObject diff --git a/src/ios/dependencies/Branch-SDK/Networking/BNCServerRequestQueue.h b/src/ios/dependencies/Branch-SDK/Networking/BNCServerRequestQueue.h index 22c10bda..2c3568b9 100755 --- a/src/ios/dependencies/Branch-SDK/Networking/BNCServerRequestQueue.h +++ b/src/ios/dependencies/Branch-SDK/Networking/BNCServerRequestQueue.h @@ -31,6 +31,6 @@ + (id)getInstance; -@property (readonly, assign) NSInteger queueDepth; -@property (readonly, assign) BOOL isDirty; +@property (readonly, assign, atomic) NSInteger queueDepth; +@property (readonly, assign, atomic) BOOL isDirty; @end diff --git a/src/ios/dependencies/Branch-SDK/Networking/BNCServerRequestQueue.m b/src/ios/dependencies/Branch-SDK/Networking/BNCServerRequestQueue.m index 84d7a50b..2bbdf8b6 100755 --- a/src/ios/dependencies/Branch-SDK/Networking/BNCServerRequestQueue.m +++ b/src/ios/dependencies/Branch-SDK/Networking/BNCServerRequestQueue.m @@ -42,6 +42,8 @@ - (id)init { } - (void) dealloc { + if (self.persistTimer) + dispatch_source_cancel(self.persistTimer); [self persistImmediately]; } @@ -86,7 +88,7 @@ - (BNCServerRequest *)removeAt:(unsigned int)index { BNCLogError(@"Invalid queue operation: index out of bound!"); return nil; } - + request = [self.queue objectAtIndex:index]; [self.queue removeObjectAtIndex:index]; [self persistEventually]; @@ -102,7 +104,9 @@ - (void)remove:(BNCServerRequest *)request { } - (BNCServerRequest *)peek { - return [self peekAt:0]; + @synchronized (self) { + return [self peekAt:0]; + } } - (BNCServerRequest *)peekAt:(unsigned int)index { @@ -111,10 +115,10 @@ - (BNCServerRequest *)peekAt:(unsigned int)index { BNCLogError(@"Invalid queue operation: index out of bound!"); return nil; } - + BNCServerRequest *request = nil; request = [self.queue objectAtIndex:index]; - + return request; } } @@ -176,7 +180,7 @@ - (BranchOpenRequest *)moveInstallOrOpenToFront:(NSInteger)networkCount { for (int i = 0; i < self.queue.count; i++) { BNCServerRequest *req = [self.queue objectAtIndex:i]; if ([req isKindOfClass:[BranchOpenRequest class]]) { - + // Already in front, nothing to do if (i == 0 || (i == 1 && requestAlreadyInProgress)) { return (BranchOpenRequest *)req; @@ -187,19 +191,19 @@ - (BranchOpenRequest *)moveInstallOrOpenToFront:(NSInteger)networkCount { break; } } - + if (!openOrInstallRequest) { BNCLogError(@"No install or open request in queue while trying to move it to the front."); return nil; } - + if (!requestAlreadyInProgress || !self.queue.count) { [self insert:openOrInstallRequest at:0]; } else { [self insert:openOrInstallRequest at:1]; } - + return (BranchOpenRequest *)openOrInstallRequest; } } @@ -235,7 +239,7 @@ - (void)persistEventually { ); __weak __typeof(self) weakSelf = self; dispatch_source_set_event_handler(self.persistTimer, ^ { - __strong __typeof(self) strongSelf = weakSelf; + __strong __typeof(weakSelf) strongSelf = weakSelf; if (strongSelf) { [strongSelf persistImmediately]; dispatch_source_cancel(strongSelf.persistTimer); @@ -248,8 +252,9 @@ - (void)persistEventually { - (void)persistImmediately { @synchronized (self) { - NSArray *requestsToPersist = [self.queue copy]; @try { + if (!self.queue) return; + NSArray *requestsToPersist = [self.queue copy]; NSMutableArray *encodedRequests = [[NSMutableArray alloc] init]; for (BNCServerRequest *req in requestsToPersist) { // Don't persist these requests @@ -290,7 +295,7 @@ - (void)retrieve { @synchronized (self) { NSMutableArray *queue = [[NSMutableArray alloc] init]; NSArray *encodedRequests = nil; - + // Capture exception while loading the queue file @try { NSError *error = nil; @@ -325,13 +330,13 @@ - (void)retrieve { BNCLogWarning(@"An exception occurred while attempting to parse a queued request, discarding."); continue; } - + // Throw out invalid request types if (![request isKindOfClass:[BNCServerRequest class]]) { BNCLogWarning(@"Found an invalid request object, discarding. Object is: %@.", request); continue; } - + // Throw out persisted close requests if ([request isKindOfClass:[BranchCloseRequest class]]) { continue; @@ -339,7 +344,7 @@ - (void)retrieve { [queue addObject:request]; } - + self.queue = queue; } } @@ -367,9 +372,9 @@ + (NSURL* _Nonnull) URLForQueueFile { + (void) moveOldQueueFile { NSURL *oldURL = [NSURL fileURLWithPath:self.queueFile_deprecated]; NSURL *newURL = [self URLForQueueFile]; - + if (!oldURL || !newURL) { return; } - + NSError *error = nil; [[NSFileManager defaultManager] moveItemAtURL:oldURL @@ -398,7 +403,7 @@ + (void) initialize { + (id)getInstance { static BNCServerRequestQueue *sharedQueue = nil; static dispatch_once_t onceToken; - + dispatch_once(&onceToken, ^ { sharedQueue = [[BNCServerRequestQueue alloc] init]; [sharedQueue retrieve]; diff --git a/src/ios/dependencies/Branch-SDK/Networking/BNCServerResponse.h b/src/ios/dependencies/Branch-SDK/Networking/BNCServerResponse.h index d256ca5b..1dc0fa72 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/BNCServerResponse.h +++ b/src/ios/dependencies/Branch-SDK/Networking/BNCServerResponse.h @@ -6,7 +6,7 @@ // Copyright (c) 2014 Branch Metrics. All rights reserved. // -#import +@import Foundation; @interface BNCServerResponse : NSObject diff --git a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchCreditHistoryRequest.m b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchCreditHistoryRequest.m index eba20a91..845bd22d 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchCreditHistoryRequest.m +++ b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchCreditHistoryRequest.m @@ -23,7 +23,7 @@ @interface BranchCreditHistoryRequest () @implementation BranchCreditHistoryRequest - (id)initWithBucket:(NSString *)bucket creditTransactionId:(NSString *)creditTransactionId length:(NSInteger)length order:(BranchCreditHistoryOrder)order callback:(callbackWithList)callback { - if (self = [super init]) { + if ((self = [super init])) { _bucket = bucket; _creditTransactionId = creditTransactionId; _length = length; diff --git a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchInstallRequest.m b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchInstallRequest.m index 4ef00d47..8478ecb5 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchInstallRequest.m +++ b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchInstallRequest.m @@ -38,12 +38,12 @@ - (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key ca params[BRANCH_REQUEST_KEY_DEBUG] = @(preferenceHelper.isDebug); - if (preferenceHelper.appleSearchAdDetails) { + if (preferenceHelper.appleSearchAdNeedsSend) { NSString *encodedSearchData = nil; @try { NSData *jsonData = [BNCEncodingUtils encodeDictionaryToJsonData:preferenceHelper.appleSearchAdDetails]; encodedSearchData = [BNCEncodingUtils base64EncodeData:jsonData]; - } @catch (id e) { } + } @catch (id) { } [self safeSetValue:encodedSearchData forKey:BRANCH_REQUEST_KEY_SEARCH_AD onDict:params]; diff --git a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchLoadRewardsRequest.m b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchLoadRewardsRequest.m index 4f283d0e..2a2d5506 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchLoadRewardsRequest.m +++ b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchLoadRewardsRequest.m @@ -19,7 +19,7 @@ @interface BranchLoadRewardsRequest () @implementation BranchLoadRewardsRequest - (id)initWithCallback:(callbackWithStatus)callback { - if (self = [super init]) { + if ((self = [super init])) { _callback = callback; } diff --git a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchLogoutRequest.m b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchLogoutRequest.m index 3955644a..1a1bdc7b 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchLogoutRequest.m +++ b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchLogoutRequest.m @@ -20,7 +20,7 @@ @interface BranchLogoutRequest () @implementation BranchLogoutRequest - (id)initWithCallback:(callbackWithStatus)callback { - if (self = [super init]) { + if ((self = [super init])) { _callback = callback; } diff --git a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchOpenRequest.m b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchOpenRequest.m index 482c5eaf..efe9ffd0 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchOpenRequest.m +++ b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchOpenRequest.m @@ -33,7 +33,7 @@ - (id)initWithCallback:(callbackWithStatus)callback { } - (id)initWithCallback:(callbackWithStatus)callback isInstall:(BOOL)isInstall { - if (self = [super init]) { + if ((self = [super init])) { _callback = callback; _isInstall = isInstall; } @@ -57,8 +57,10 @@ - (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key ca [self safeSetValue:[BNCSystemObserver getAppVersion] forKey:BRANCH_REQUEST_KEY_APP_VERSION onDict:params]; [self safeSetValue:[BNCSystemObserver getDefaultUriScheme] forKey:BRANCH_REQUEST_KEY_URI_SCHEME onDict:params]; [self safeSetValue:[BNCSystemObserver getUpdateState] forKey:BRANCH_REQUEST_KEY_UPDATE onDict:params]; - [self safeSetValue:[NSNumber numberWithBool:preferenceHelper.checkedFacebookAppLinks] forKey:BRANCH_REQUEST_KEY_CHECKED_FACEBOOK_APPLINKS onDict:params]; - [self safeSetValue:[NSNumber numberWithBool:preferenceHelper.checkedAppleSearchAdAttribution] forKey:BRANCH_REQUEST_KEY_CHECKED_APPLE_AD_ATTRIBUTION onDict:params]; + [self safeSetValue:[NSNumber numberWithBool:preferenceHelper.checkedFacebookAppLinks] + forKey:BRANCH_REQUEST_KEY_CHECKED_FACEBOOK_APPLINKS onDict:params]; + [self safeSetValue:[NSNumber numberWithBool:preferenceHelper.checkedAppleSearchAdAttribution] + forKey:BRANCH_REQUEST_KEY_CHECKED_APPLE_AD_ATTRIBUTION onDict:params]; [self safeSetValue:preferenceHelper.linkClickIdentifier forKey:BRANCH_REQUEST_KEY_LINK_IDENTIFIER onDict:params]; [self safeSetValue:preferenceHelper.spotlightIdentifier forKey:BRANCH_REQUEST_KEY_SPOTLIGHT_IDENTIFIER onDict:params]; [self safeSetValue:preferenceHelper.universalLinkUrl forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:params]; @@ -70,17 +72,16 @@ - (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key ca [cdDict bnc_safeSetObject:[BNCSystemObserver getBundleID] forKey:BRANCH_BUNDLE_IDENTIFIER]; [self safeSetValue:cdDict forKey:BRANCH_CONTENT_DISCOVER_KEY onDict:params]; - if (preferenceHelper.appleSearchAdDetails) { + if (preferenceHelper.appleSearchAdNeedsSend) { NSString *encodedSearchData = nil; @try { NSData *jsonData = [BNCEncodingUtils encodeDictionaryToJsonData:preferenceHelper.appleSearchAdDetails]; encodedSearchData = [BNCEncodingUtils base64EncodeData:jsonData]; - } @catch (id e) { } + } @catch (id) { } [self safeSetValue:encodedSearchData forKey:BRANCH_REQUEST_KEY_SEARCH_AD onDict:params]; } - /**/ [serverInterface postRequest:params url:[preferenceHelper getAPIURL:BRANCH_REQUEST_ENDPOINT_OPEN] key:key callback:callback]; } @@ -186,7 +187,7 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error { preferenceHelper.spotlightIdentifier = nil; preferenceHelper.universalLinkUrl = nil; preferenceHelper.externalIntentURI = nil; - preferenceHelper.appleSearchAdDetails = nil; + preferenceHelper.appleSearchAdNeedsSend = NO; if (data[BRANCH_RESPONSE_KEY_BRANCH_IDENTITY]) { preferenceHelper.identityID = data[BRANCH_RESPONSE_KEY_BRANCH_IDENTITY]; diff --git a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchRedeemRewardsRequest.m b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchRedeemRewardsRequest.m index f0e799cd..3f416058 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchRedeemRewardsRequest.m +++ b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchRedeemRewardsRequest.m @@ -21,7 +21,7 @@ @interface BranchRedeemRewardsRequest () @implementation BranchRedeemRewardsRequest - (id)initWithAmount:(NSInteger)amount bucket:(NSString *)bucket callback:(callbackWithStatus)callback { - if (self = [super init]) { + if ((self = [super init])) { _amount = amount; _bucket = bucket; _callback = callback; @@ -65,7 +65,7 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error { #pragma mark - NSCoding methods - (id)initWithCoder:(NSCoder *)decoder { - if (self = [super initWithCoder:decoder]) { + if ((self = [super initWithCoder:decoder])) { _amount = [decoder decodeIntegerForKey:@"amount"]; _bucket = [decoder decodeObjectForKey:@"bucket"]; } diff --git a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchRegisterViewRequest.m b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchRegisterViewRequest.m index db8f30cb..88159655 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchRegisterViewRequest.m +++ b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchRegisterViewRequest.m @@ -21,7 +21,7 @@ @interface BranchRegisterViewRequest () @implementation BranchRegisterViewRequest - (id)initWithParams:(NSDictionary *)params andCallback:(callbackWithParams)callback { - if (self = [super init]) { + if ((self = [super init])) { _params = params; if (!_params) { _params = [[NSDictionary alloc] init]; @@ -66,7 +66,7 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error { #pragma mark - NSCoding methods - (id)initWithCoder:(NSCoder *)decoder { - if (self = [super initWithCoder:decoder]) { + if ((self = [super initWithCoder:decoder])) { _params = [decoder decodeObjectForKey:@"params"]; } diff --git a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchSetIdentityRequest.m b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchSetIdentityRequest.m index 14fc3f43..a53fc67a 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchSetIdentityRequest.m +++ b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchSetIdentityRequest.m @@ -22,7 +22,7 @@ @interface BranchSetIdentityRequest () @implementation BranchSetIdentityRequest - (id)initWithUserId:(NSString *)userId callback:(callbackWithParams)callback { - if (self = [super init]) { + if ((self = [super init])) { _userId = userId; _callback = callback; _shouldCallCallback = YES; diff --git a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchShortUrlRequest.m b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchShortUrlRequest.m index ad53df97..c0980f20 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchShortUrlRequest.m +++ b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchShortUrlRequest.m @@ -31,7 +31,7 @@ @interface BranchShortUrlRequest () @implementation BranchShortUrlRequest - (id)initWithTags:(NSArray *)tags alias:(NSString *)alias type:(BranchLinkType)type matchDuration:(NSInteger)duration channel:(NSString *)channel feature:(NSString *)feature stage:(NSString *)stage campaign:campaign params:(NSDictionary *)params linkData:(BNCLinkData *)linkData linkCache:(BNCLinkCache *)linkCache callback:(callbackWithUrl)callback { - if (self = [super init]) { + if ((self = [super init])) { _tags = tags; _alias = alias; _type = type; @@ -56,7 +56,7 @@ - (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key ca BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper preferenceHelper]; params[BRANCH_REQUEST_KEY_DEVICE_FINGERPRINT_ID] = preferenceHelper.deviceFingerprintID; - if (!_isSpotlightRequest && _alias.length == 0) { + if (!_isSpotlightRequest) { params[BRANCH_REQUEST_KEY_BRANCH_IDENTITY] = preferenceHelper.identityID; } params[BRANCH_REQUEST_KEY_SESSION_ID] = preferenceHelper.sessionID; @@ -127,7 +127,7 @@ - (NSString *)createLongUrlForUserUrl:(NSString *)userUrl { #pragma mark - NSCoding methods - (id)initWithCoder:(NSCoder *)decoder { - if (self = [super initWithCoder:decoder]) { + if ((self = [super initWithCoder:decoder])) { _tags = [decoder decodeObjectForKey:@"tags"]; _alias = [decoder decodeObjectForKey:@"alias"]; _type = [decoder decodeIntegerForKey:@"type"]; diff --git a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchShortUrlSyncRequest.h b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchShortUrlSyncRequest.h index f6008328..ffd69a4b 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchShortUrlSyncRequest.h +++ b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchShortUrlSyncRequest.h @@ -6,7 +6,7 @@ // Copyright (c) 2015 Branch Metrics. All rights reserved. // -#import +@import Foundation; #import "Branch.h" @interface BranchShortUrlSyncRequest : NSObject diff --git a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchShortUrlSyncRequest.m b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchShortUrlSyncRequest.m index 17c38a8d..9d06b91f 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchShortUrlSyncRequest.m +++ b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchShortUrlSyncRequest.m @@ -32,7 +32,7 @@ @interface BranchShortUrlSyncRequest () @implementation BranchShortUrlSyncRequest - (id)initWithTags:(NSArray *)tags alias:(NSString *)alias type:(BranchLinkType)type matchDuration:(NSInteger)duration channel:(NSString *)channel feature:(NSString *)feature stage:(NSString *)stage campaign:(NSString *)campaign params:(NSDictionary *)params linkData:(BNCLinkData *)linkData linkCache:(BNCLinkCache *)linkCache { - if (self = [super init]) { + if ((self = [super init])) { _tags = tags; _alias = alias; _type = type; @@ -54,8 +54,7 @@ - (BNCServerResponse *)makeRequest:(BNCServerInterface *)serverInterface key:(NS BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper preferenceHelper]; params[BRANCH_REQUEST_KEY_DEVICE_FINGERPRINT_ID] = preferenceHelper.deviceFingerprintID; - if (_alias.length == 0) - params[BRANCH_REQUEST_KEY_BRANCH_IDENTITY] = preferenceHelper.identityID; + params[BRANCH_REQUEST_KEY_BRANCH_IDENTITY] = preferenceHelper.identityID; params[BRANCH_REQUEST_KEY_SESSION_ID] = preferenceHelper.sessionID; return [serverInterface postRequestSynchronous:params diff --git a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchUserCompletedActionRequest.m b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchUserCompletedActionRequest.m index 4660910e..49f2f919 100644 --- a/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchUserCompletedActionRequest.m +++ b/src/ios/dependencies/Branch-SDK/Networking/Requests/BranchUserCompletedActionRequest.m @@ -28,7 +28,7 @@ - (id)initWithAction:(NSString *)action state:(NSDictionary *)state { } - (id)initWithAction:(NSString *)action state:(NSDictionary *)state withBranchViewCallback:(id)callback { - if (self = [super init]) { + if ((self = [super init])) { _action = action; _state = state; _branchViewcallback = callback; @@ -76,7 +76,7 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error { #pragma mark - NSCoding methods - (id)initWithCoder:(NSCoder *)decoder { - if (self = [super initWithCoder:decoder]) { + if ((self = [super initWithCoder:decoder])) { _action = [decoder decodeObjectForKey:@"action"]; _state = [decoder decodeObjectForKey:@"state"]; }