diff --git a/Branch-TestBed/Branch-SDK-Tests/BNCClassSerializationTests.m b/Branch-TestBed/Branch-SDK-Tests/BNCClassSerializationTests.m deleted file mode 100644 index f1af287d9..000000000 --- a/Branch-TestBed/Branch-SDK-Tests/BNCClassSerializationTests.m +++ /dev/null @@ -1,120 +0,0 @@ -// -// BNCClassSerializationTests.m -// Branch-SDK-Tests -// -// Created by Ernest Cho on 3/28/24. -// Copyright © 2024 Branch, Inc. All rights reserved. -// - -#import -#import "BranchEvent.h" -#import "BranchOpenRequest.h" -#import "BranchInstallRequest.h" - -@interface BranchEvent() -// private BranchEvent methods used to build a BranchEventRequest -- (NSDictionary *)buildEventDictionary; -@end - -@interface BranchOpenRequest() -- (NSString *)getActionName; -@end - -@interface BNCClassSerializationTests : XCTestCase - -@end - -// Test serialization of replayable requests -@implementation BNCClassSerializationTests - -- (void)setUp { - // Put setup code here. This method is called before the invocation of each test method in the class. -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. -} - -// BranchEventRequest is creation is tightly coupled with the BranchEvent class -// In order to test building it, we need to expose some private methods. :( -- (BranchEventRequest *)buildBranchEventRequest { - BranchEvent *event = [BranchEvent standardEvent:BranchStandardEventPurchase]; - NSURL *url = [NSURL URLWithString:@"https://api3.branch.io/v2/event/standard"]; - NSDictionary *eventDictionary = [event buildEventDictionary]; - - BranchEventRequest *request = [[BranchEventRequest alloc] initWithServerURL:url eventDictionary:eventDictionary completion:nil]; - return request; -} - -- (void)testBranchEventRequestArchive { - BranchEventRequest *request = [self buildBranchEventRequest]; - - // archive the event - NSError *error = nil; - NSData *data = [NSKeyedArchiver archivedDataWithRootObject:request requiringSecureCoding:YES error:&error]; - XCTAssertNil(error); - XCTAssertNotNil(data); - - // unarchive the event - id object = [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithArray:@[BranchEventRequest.class]] fromData:data error:&error]; - XCTAssertNil(error); - XCTAssertNotNil(object); - - // check object - XCTAssertTrue([object isKindOfClass:BranchEventRequest.class]); - BranchEventRequest *unarchivedRequest = (BranchEventRequest *)object; - - XCTAssertTrue([request.serverURL.absoluteString isEqualToString:unarchivedRequest.serverURL.absoluteString]); - XCTAssertTrue(request.eventDictionary.count == unarchivedRequest.eventDictionary.count); - XCTAssertNil(unarchivedRequest.completion); -} - -- (void)testBranchOpenRequestArchive { - BranchOpenRequest *request = [[BranchOpenRequest alloc] initWithCallback:nil]; - request.urlString = @"https://branch.io"; - - // archive the event - NSError *error = nil; - NSData *data = [NSKeyedArchiver archivedDataWithRootObject:request requiringSecureCoding:YES error:&error]; - XCTAssertNil(error); - XCTAssertNotNil(data); - - // unarchive the event - id object = [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithArray:@[BranchOpenRequest.class]] fromData:data error:&error]; - XCTAssertNil(error); - XCTAssertNotNil(object); - - // check object - XCTAssertTrue([object isKindOfClass:BranchOpenRequest.class]); - BranchOpenRequest *unarchivedRequest = (BranchOpenRequest *)object; - - XCTAssertTrue([request.urlString isEqualToString:unarchivedRequest.urlString]); - XCTAssertNil(unarchivedRequest.callback); - XCTAssertTrue([@"open" isEqualToString:[unarchivedRequest getActionName]]); -} - -- (void)testBranchInstallRequestArchive { - BranchInstallRequest *request = [[BranchInstallRequest alloc] initWithCallback:nil]; - request.urlString = @"https://branch.io"; - - // archive the event - NSError *error = nil; - NSData *data = [NSKeyedArchiver archivedDataWithRootObject:request requiringSecureCoding:YES error:&error]; - XCTAssertNil(error); - XCTAssertNotNil(data); - - // unarchive the event - id object = [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithArray:@[BranchInstallRequest.class]] fromData:data error:&error]; - XCTAssertNil(error); - XCTAssertNotNil(object); - - // check object - XCTAssertTrue([object isKindOfClass:BranchInstallRequest.class]); - BranchInstallRequest *unarchivedRequest = (BranchInstallRequest *)object; - - XCTAssertTrue([request.urlString isEqualToString:unarchivedRequest.urlString]); - XCTAssertNil(unarchivedRequest.callback); - XCTAssertTrue([@"install" isEqualToString:[unarchivedRequest getActionName]]); -} - -@end diff --git a/Branch-TestBed/Branch-SDK-Tests/BNCServerRequestQueueTests.m b/Branch-TestBed/Branch-SDK-Tests/BNCServerRequestQueueTests.m deleted file mode 100644 index 3dbbdd4fe..000000000 --- a/Branch-TestBed/Branch-SDK-Tests/BNCServerRequestQueueTests.m +++ /dev/null @@ -1,372 +0,0 @@ -// -// BNCServerRequestQueueTests.m -// Branch-SDK-Tests -// -// Created by Ernest Cho on 5/14/21. -// Copyright © 2021 Branch, Inc. All rights reserved. -// - -#import -#import "BNCServerRequestQueue.h" -#import "BNCServerRequest.h" - -// Analytics requests -#import "BranchInstallRequest.h" -#import "BranchOpenRequest.h" -#import "BranchEvent.h" -#import "BranchShortURLRequest.h" -#import "BranchLATDRequest.h" - -@interface BNCServerRequestQueue () -- (NSData *)archiveQueue:(NSArray *)queue; -- (NSMutableArray *)unarchiveQueueFromData:(NSData *)data; - -- (NSData *)archiveObject:(NSObject *)object; -- (id)unarchiveObjectFromData:(NSData *)data; - -// returns data in the legacy format -- (NSData *)oldArchiveQueue:(NSArray *)queue; - -+ (NSURL * _Nonnull) URLForQueueFile; -- (void)retrieve; - -@end - -@interface BNCServerRequestQueueTests : XCTestCase -@property (nonatomic, strong, readwrite) BNCServerRequestQueue *queue; -@end - -@implementation BNCServerRequestQueueTests - -- (void)setUp { - self.queue = [BNCServerRequestQueue new]; -} - -- (void)tearDown { - self.queue = nil; -} - -- (NSArray *)getQueueCachedOnDisk { - NSMutableArray *decodedQueue = nil; - NSData *data = [NSData dataWithContentsOfURL:[BNCServerRequestQueue URLForQueueFile] options:0 error:nil]; - if (data) { - decodedQueue = [_queue unarchiveQueueFromData:data]; - } - return decodedQueue; -} - -- (void)testArchiveNil { - NSString *object = nil; - - NSData *archived = [self.queue archiveObject:object]; - XCTAssertNotNil(archived); - - NSString *unarchived = [self.queue unarchiveObjectFromData:archived]; - XCTAssertNil(unarchived); -} - -- (void)testArchiveString { - NSString *object = @"Hello World"; - - NSData *archived = [self.queue archiveObject:object]; - XCTAssertNotNil(archived); - - NSString *unarchived = [self.queue unarchiveObjectFromData:archived]; - XCTAssertNotNil(unarchived); - XCTAssert([object isEqual:unarchived]); -} - -- (void)testArchiveInstallRequest { - BranchInstallRequest *object = [BranchInstallRequest new]; - - NSData *archived = [self.queue archiveObject:object]; - XCTAssertNotNil(archived); - - BranchInstallRequest *unarchived = [self.queue unarchiveObjectFromData:archived]; - XCTAssertNotNil(unarchived); - XCTAssert([unarchived isKindOfClass:[BranchInstallRequest class]]); - - // The request object is not very test friendly, so comparing the two is not helpful at the moment -} - -- (void)testArchiveOpenRequest { - BranchOpenRequest *object = [BranchOpenRequest new]; - - NSData *archived = [self.queue archiveObject:object]; - XCTAssertNotNil(archived); - - BranchOpenRequest *unarchived = [self.queue unarchiveObjectFromData:archived]; - XCTAssertNotNil(unarchived); - XCTAssert([unarchived isKindOfClass:[BranchOpenRequest class]]); - - // The request object is not very test friendly, so comparing the two is not helpful at the moment -} - -- (void)testArchiveEventRequest { - BranchEventRequest *object = [BranchEventRequest new]; - - NSData *archived = [self.queue archiveObject:object]; - XCTAssertNotNil(archived); - - BranchEventRequest *unarchived = [self.queue unarchiveObjectFromData:archived]; - XCTAssertNotNil(unarchived); - XCTAssert([unarchived isKindOfClass:[BranchEventRequest class]]); - - // The request object is not very test friendly, so comparing the two is not helpful at the moment -} - -- (void)testArchiveArrayOfRequests { - NSMutableArray *tmp = [NSMutableArray new]; - [tmp addObject:[BranchOpenRequest new]]; - [tmp addObject:[BranchEventRequest new]]; - - NSData *data = [self.queue archiveQueue:tmp]; - XCTAssertNotNil(data); - - NSMutableArray *unarchived = [self.queue unarchiveQueueFromData:data]; - XCTAssertNotNil(unarchived); - XCTAssert(unarchived.count == 2); -} - -- (void)testOldArchiveArrayOfRequests { - NSMutableArray *tmp = [NSMutableArray new]; - [tmp addObject:[BranchOpenRequest new]]; - [tmp addObject:[BranchEventRequest new]]; - - NSData *data = [self.queue oldArchiveQueue:tmp]; - XCTAssertNotNil(data); - - NSMutableArray *unarchived = [self.queue unarchiveQueueFromData:data]; - XCTAssertNotNil(unarchived); - XCTAssert(unarchived.count == 2); -} - -- (void)testArchiveArrayOfInvalidObjects { - NSMutableArray *tmp = [NSMutableArray new]; - [tmp addObject:[BranchOpenRequest new]]; - [tmp addObject:@"Hello World"]; - [tmp addObject:[BranchEventRequest new]]; - - NSData *data = [self.queue archiveQueue:tmp]; - XCTAssertNotNil(data); - - NSMutableArray *unarchived = [self.queue unarchiveQueueFromData:data]; - - XCTAssertNotNil(unarchived); - XCTAssert(unarchived.count == 2); -} - -- (void)testOldArchiveArrayOfInvalidObjects { - NSMutableArray *tmp = [NSMutableArray new]; - [tmp addObject:[BranchOpenRequest new]]; - [tmp addObject:@"Hello World"]; - [tmp addObject:[BranchEventRequest new]]; - - NSData *data = [self.queue oldArchiveQueue:tmp]; - XCTAssertNotNil(data); - - NSMutableArray *unarchived = [self.queue unarchiveQueueFromData:data]; - - XCTAssertNotNil(unarchived); - XCTAssert(unarchived.count == 2); -} - -- (void)testMultipleRequests { - BranchEventRequest *eventObject = [BranchEventRequest new]; - BranchOpenRequest *openObject = [BranchOpenRequest new]; - - [_queue enqueue: eventObject]; - [_queue enqueue: openObject]; - [_queue persistImmediately]; - - NSArray *decodedQueue = [self getQueueCachedOnDisk]; - - XCTAssert([decodedQueue count] == 2); - [_queue clearQueue]; - XCTAssert([_queue queueDepth] == 0); - [_queue retrieve]; - XCTAssert([_queue queueDepth] == 2); - - // Request are loaded. So there should not be any queue file on disk. - XCTAssert([NSFileManager.defaultManager fileExistsAtPath:[[BNCServerRequestQueue URLForQueueFile] path]] == NO); -} - -- (void)testUUIDANDTimeStampPersistence { - BranchEventRequest *eventObject = [BranchEventRequest new]; - BranchOpenRequest *openObject = [BranchOpenRequest new]; - NSString *uuidFromEventObject = eventObject.requestUUID; - NSNumber *timeStampFromEventObject = eventObject.requestCreationTimeStamp; - NSString *uuidFromOpenObject = openObject.requestUUID; - NSNumber *timeStampFromOpenObject = openObject.requestCreationTimeStamp; - - XCTAssertTrue(![uuidFromEventObject isEqualToString:uuidFromOpenObject]); - - [_queue enqueue: eventObject]; - [_queue enqueue: openObject]; - [_queue persistImmediately]; - - NSArray *decodedQueue = [self getQueueCachedOnDisk]; - - for (id requestObject in decodedQueue) { - if ([requestObject isKindOfClass:BranchEventRequest.class]) { - XCTAssertTrue([uuidFromEventObject isEqualToString:[(BranchEventRequest *)requestObject requestUUID]]); - XCTAssertTrue([timeStampFromEventObject isEqualToNumber:[(BranchEventRequest *)requestObject requestCreationTimeStamp]]); - } - if ([requestObject isKindOfClass:BranchOpenRequest.class]) { - XCTAssertTrue([uuidFromOpenObject isEqualToString:[(BranchOpenRequest *)requestObject requestUUID]]); - XCTAssertTrue([timeStampFromOpenObject isEqualToNumber:[(BranchOpenRequest *)requestObject requestCreationTimeStamp]]); - } - } -} - -- (void)testUUIDANDTimeStampPersistenceForOpen { - BranchOpenRequest *openObject = [[BranchOpenRequest alloc] init]; - BranchOpenRequest *openWithCallbackObject = [[BranchOpenRequest alloc] initWithCallback:^(BOOL changed, NSError * _Nullable error) {}]; - openObject.urlString = @"https://www.branch.io"; - openWithCallbackObject.urlString = @"https://www.branch.testWithCallback.io"; - [_queue enqueue: openObject]; - [_queue enqueue: openWithCallbackObject]; - [_queue persistImmediately]; - - NSArray *decodedQueue = [self getQueueCachedOnDisk]; - - for (id requestObject in decodedQueue) { - if ([requestObject isKindOfClass:BranchOpenRequest.class]) { - BranchOpenRequest *tmpCopy = (BranchOpenRequest *)requestObject; - if ([tmpCopy.urlString isEqualToString:openObject.urlString]) { - XCTAssertTrue([tmpCopy.requestUUID isEqualToString:openObject.requestUUID]); - XCTAssertTrue([tmpCopy.requestCreationTimeStamp isEqualToNumber:openObject.requestCreationTimeStamp]); - } else if ([tmpCopy.urlString isEqualToString:openWithCallbackObject.urlString]) { - XCTAssertTrue([tmpCopy.requestUUID isEqualToString:openWithCallbackObject.requestUUID]); - XCTAssertTrue([tmpCopy.requestCreationTimeStamp isEqualToNumber:openWithCallbackObject.requestCreationTimeStamp]); - } else { - XCTFail("Invalid URL found"); - } - - } else { - XCTFail("Invalid Object type found"); - } - } -} - -- (void)testUUIDANDTimeStampPersistenceForInstall { - BranchInstallRequest *installObject = [[BranchInstallRequest alloc] init]; - BranchInstallRequest *installWithCallbackObject = [[BranchInstallRequest alloc] initWithCallback:^(BOOL changed, NSError * _Nullable error) {}]; - installObject.urlString = @"https://www.branch.io"; - installWithCallbackObject.urlString = @"https://www.branch.testWithCallback.io"; - [_queue enqueue: installObject]; - [_queue enqueue: installWithCallbackObject]; - [_queue persistImmediately]; - - NSArray *decodedQueue = [self getQueueCachedOnDisk]; - - for (id requestObject in decodedQueue) { - if ([requestObject isKindOfClass:BranchInstallRequest.class]) { - BranchInstallRequest *tmpCopy = (BranchInstallRequest *)requestObject; - if ([tmpCopy.urlString isEqualToString:installObject.urlString]) { - XCTAssertTrue([tmpCopy.requestUUID isEqualToString:installObject.requestUUID]); - XCTAssertTrue([tmpCopy.requestCreationTimeStamp isEqualToNumber:installObject.requestCreationTimeStamp]); - } else if ([tmpCopy.urlString isEqualToString:installWithCallbackObject.urlString]) { - XCTAssertTrue([tmpCopy.requestUUID isEqualToString:installWithCallbackObject.requestUUID]); - XCTAssertTrue([tmpCopy.requestCreationTimeStamp isEqualToNumber:installWithCallbackObject.requestCreationTimeStamp]); - } else { - XCTFail("Invalid URL found"); - } - } else { - XCTFail("Invalid Object type found"); - } - } -} - -- (void)testUUIDANDTimeStampPersistenceForEvent { - BranchEventRequest *eventObject = [[BranchEventRequest alloc] init]; - [_queue enqueue: eventObject]; - [_queue persistImmediately]; - - NSArray *decodedQueue = [self getQueueCachedOnDisk]; - - for (id requestObject in decodedQueue) { - if ([requestObject isKindOfClass:BranchEventRequest.class]) { - XCTAssertTrue([eventObject.requestUUID isEqualToString:((BranchEventRequest *)requestObject).requestUUID]); - XCTAssertTrue([eventObject.requestCreationTimeStamp isEqualToNumber:((BranchEventRequest *)requestObject).requestCreationTimeStamp]); - } else { - XCTFail("Invalid Object type found"); - } - } -} - -- (void)testUUIDANDTimeStampPersistenceForEventWithCallback { - - NSURL *url = [NSURL URLWithString:@"https://api3.branch.io/v2/event/standard"]; - BranchEventRequest *eventObject = [[BranchEventRequest alloc] initWithServerURL:url eventDictionary:nil completion:nil]; - - [_queue enqueue: eventObject]; - [_queue persistImmediately]; - - NSArray *decodedQueue = [self getQueueCachedOnDisk]; - - for (id requestObject in decodedQueue) { - if ([requestObject isKindOfClass:BranchEventRequest.class]) { - XCTAssertTrue([eventObject.requestUUID isEqualToString:((BranchEventRequest *)requestObject).requestUUID]); - XCTAssertTrue([eventObject.requestCreationTimeStamp isEqualToNumber:((BranchEventRequest *)requestObject).requestCreationTimeStamp]); - } else { - XCTFail("Invalid Object type found"); - } - } -} - -- (void)testUUIDANDTimeStampPersistenceForShortURL { - BranchShortUrlRequest *shortURLObject = [BranchShortUrlRequest new]; - [_queue enqueue: shortURLObject]; - [_queue persistImmediately]; - - NSArray *decodedQueue = [self getQueueCachedOnDisk]; - - for (id requestObject in decodedQueue) { - if ([requestObject isKindOfClass:BranchShortUrlRequest.class]) { - XCTAssertTrue([shortURLObject.requestUUID isEqualToString:((BranchShortUrlRequest *)requestObject).requestUUID]); - XCTAssertTrue([shortURLObject.requestCreationTimeStamp isEqualToNumber:((BranchShortUrlRequest *)requestObject).requestCreationTimeStamp]); - } else { - XCTFail("Invalid Object type found"); - } - } -} - -- (void)testUUIDANDTimeStampPersistenceForShortURLWithParams { - - BranchShortUrlRequest *shortURLObject = [[BranchShortUrlRequest alloc] initWithTags:nil alias:nil type:BranchLinkTypeUnlimitedUse matchDuration:0 channel:nil feature:nil stage:nil campaign:nil params:nil linkData:nil linkCache:nil callback:^(NSString * _Nullable url, NSError * _Nullable error) {}]; - [_queue enqueue: shortURLObject]; - [_queue persistImmediately]; - - NSArray *decodedQueue = [self getQueueCachedOnDisk]; - - for (id requestObject in decodedQueue) { - if ([requestObject isKindOfClass:BranchShortUrlRequest.class]) { - XCTAssertTrue([shortURLObject.requestUUID isEqualToString:((BranchShortUrlRequest *)requestObject).requestUUID]); - XCTAssertTrue([shortURLObject.requestCreationTimeStamp isEqualToNumber:((BranchShortUrlRequest *)requestObject).requestCreationTimeStamp]); - } else { - XCTFail("Invalid Object type found"); - } - } -} - -- (void)testUUIDANDTimeStampPersistenceForLATD { - - BranchLATDRequest *latdObject = [BranchLATDRequest new]; - [_queue enqueue: latdObject]; - [_queue persistImmediately]; - - NSArray *decodedQueue = [self getQueueCachedOnDisk]; - - for (id requestObject in decodedQueue) { - if ([requestObject isKindOfClass:BranchLATDRequest.class]) { - XCTAssertTrue([latdObject.requestUUID isEqualToString:((BranchLATDRequest *)requestObject).requestUUID]); - XCTAssertTrue([latdObject.requestCreationTimeStamp isEqualToNumber:((BranchLATDRequest *)requestObject).requestCreationTimeStamp]); - } else { - XCTFail("Invalid Object type found"); - } - } -} - - -@end diff --git a/Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj b/Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj index 23e32a6c7..23c7ab5fa 100644 --- a/Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj +++ b/Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj @@ -187,8 +187,6 @@ 5F644C482B7AA811000DCD78 /* BNCCallbackMap.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F644BB72B7AA811000DCD78 /* BNCCallbackMap.m */; }; 5F644C492B7AA811000DCD78 /* BNCEventUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F644BB82B7AA811000DCD78 /* BNCEventUtils.m */; }; 5F67F48E228F535500067429 /* BNCEncodingUtilsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F67F48D228F535500067429 /* BNCEncodingUtilsTests.m */; }; - 5F6D86D92BB5E9650068B536 /* BNCClassSerializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F6D86D82BB5E9650068B536 /* BNCClassSerializationTests.m */; }; - 5F83B9ED2433BAAA0054A022 /* BNCServerInterface.Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D16837E2098C901008819E3 /* BNCServerInterface.Test.m */; }; 5F86501A2B76DA3200364BDE /* NSMutableDictionaryBranchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F8650192B76DA3200364BDE /* NSMutableDictionaryBranchTests.m */; }; 5F892EC5236116CD0023AEC1 /* NSErrorBranchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F892EC4236116CC0023AEC1 /* NSErrorBranchTests.m */; }; 5F8B7B4021B5F5CD009CE0A6 /* libBranch.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 466B58381B17773000A69EDE /* libBranch.a */; }; @@ -200,7 +198,6 @@ 5F92B2362383644C00CA909B /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F92B2352383644C00CA909B /* SystemConfiguration.framework */; }; 5F92B242238752A500CA909B /* BNCDeviceInfoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F92B241238752A500CA909B /* BNCDeviceInfoTests.m */; }; 5FA9112F29BC662000F3D35C /* BNCNetworkInterfaceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FA9112E29BC662000F3D35C /* BNCNetworkInterfaceTests.m */; }; - 5FB6CC13264F0C7C0020E478 /* BNCServerRequestQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FB6CC12264F0C7C0020E478 /* BNCServerRequestQueueTests.m */; }; 5FC20E732A93D85F00D9E1C8 /* BNCRequestFactoryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FC20E722A93D85F00D9E1C8 /* BNCRequestFactoryTests.m */; }; 5FC4CF8C24860C440001E701 /* latd.json in Resources */ = {isa = PBXBuildFile; fileRef = 5FC4CF7E24860C320001E701 /* latd.json */; }; 5FC4CF8D24860C440001E701 /* latd_missing_window.json in Resources */ = {isa = PBXBuildFile; fileRef = 5FC4CF7F24860C320001E701 /* latd_missing_window.json */; }; @@ -477,7 +474,6 @@ 5F644BB72B7AA811000DCD78 /* BNCCallbackMap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCCallbackMap.m; sourceTree = ""; }; 5F644BB82B7AA811000DCD78 /* BNCEventUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCEventUtils.m; sourceTree = ""; }; 5F67F48D228F535500067429 /* BNCEncodingUtilsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCEncodingUtilsTests.m; sourceTree = ""; }; - 5F6D86D82BB5E9650068B536 /* BNCClassSerializationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCClassSerializationTests.m; sourceTree = ""; }; 5F73FC8023314697000EBD32 /* BNCJSONUtilityTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCJSONUtilityTests.m; sourceTree = ""; }; 5F8650192B76DA3200364BDE /* NSMutableDictionaryBranchTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSMutableDictionaryBranchTests.m; sourceTree = ""; }; 5F892EC4236116CC0023AEC1 /* NSErrorBranchTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSErrorBranchTests.m; sourceTree = ""; }; @@ -490,7 +486,6 @@ 5F92B2352383644C00CA909B /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; }; 5F92B241238752A500CA909B /* BNCDeviceInfoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCDeviceInfoTests.m; sourceTree = ""; }; 5FA9112E29BC662000F3D35C /* BNCNetworkInterfaceTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCNetworkInterfaceTests.m; sourceTree = ""; }; - 5FB6CC12264F0C7C0020E478 /* BNCServerRequestQueueTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCServerRequestQueueTests.m; sourceTree = ""; }; 5FC20E722A93D85F00D9E1C8 /* BNCRequestFactoryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCRequestFactoryTests.m; sourceTree = ""; }; 5FC4CF7E24860C320001E701 /* latd.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = latd.json; sourceTree = ""; }; 5FC4CF7F24860C320001E701 /* latd_missing_window.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = latd_missing_window.json; sourceTree = ""; }; @@ -629,7 +624,6 @@ 5F92B23323835FEB00CA909B /* BNCReachabilityTests.m */, C1CC888129BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m */, 5FC20E722A93D85F00D9E1C8 /* BNCRequestFactoryTests.m */, - 5FB6CC12264F0C7C0020E478 /* BNCServerRequestQueueTests.m */, 5FDB04F324E6156800F2F267 /* BNCSKAdNetworkTests.m */, 4D16838F2098C901008819E3 /* BNCSystemObserverTests.m */, 5FCF7EAC29DC96A7008D629E /* BNCURLFilterSkiplistUpgradeTests.m */, @@ -651,7 +645,6 @@ 5F892EC4236116CC0023AEC1 /* NSErrorBranchTests.m */, 5F8650192B76DA3200364BDE /* NSMutableDictionaryBranchTests.m */, 4D16839E2098C901008819E3 /* NSStringBranchTests.m */, - 5F6D86D82BB5E9650068B536 /* BNCClassSerializationTests.m */, ); path = "Branch-SDK-Tests"; sourceTree = ""; @@ -1375,7 +1368,6 @@ C15CC9DE2ABCB549003CC339 /* BNCCurrencyTests.m in Sources */, 5F205D0823186AF700C776D1 /* BNCUserAgentCollectorTests.m in Sources */, 5FCF7EAD29DC96A7008D629E /* BNCURLFilterSkiplistUpgradeTests.m in Sources */, - 5F6D86D92BB5E9650068B536 /* BNCClassSerializationTests.m in Sources */, E7A728BD2AA9A112009343B7 /* BNCAPIServerTest.m in Sources */, 4D1683C12098C902008819E3 /* BNCApplicationTests.m in Sources */, 4D1683B92098C902008819E3 /* BNCSystemObserverTests.m in Sources */, @@ -1386,7 +1378,6 @@ C1CC888229BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m in Sources */, 5FE694382405FA2700E3AEE2 /* BNCCallbackMapTests.m in Sources */, 5FDB04F424E6156800F2F267 /* BNCSKAdNetworkTests.m in Sources */, - 5FB6CC13264F0C7C0020E478 /* BNCServerRequestQueueTests.m in Sources */, 4D1683AE2098C902008819E3 /* BNCLinkDataTests.m in Sources */, C15CC9E02ABCF8C8003CC339 /* BranchActivityItemTests.m in Sources */, 5F92B23423835FEB00CA909B /* BNCReachabilityTests.m in Sources */, diff --git a/Sources/BranchSDK/BNCLinkData.m b/Sources/BranchSDK/BNCLinkData.m index 2d839bf8e..12cee4225 100644 --- a/Sources/BranchSDK/BNCLinkData.m +++ b/Sources/BranchSDK/BNCLinkData.m @@ -137,57 +137,5 @@ - (NSUInteger)hash { return result; } -- (void)encodeWithCoder:(NSCoder *)coder { - if (self.tags) { - [coder encodeObject:self.tags forKey:BRANCH_REQUEST_KEY_URL_TAGS]; - } - if (self.alias) { - [coder encodeObject:self.alias forKey:BRANCH_REQUEST_KEY_URL_ALIAS]; - } - if (self.type) { - [coder encodeObject:@(self.type) forKey:BRANCH_REQUEST_KEY_URL_LINK_TYPE]; - } - if (self.channel) { - [coder encodeObject:self.channel forKey:BRANCH_REQUEST_KEY_URL_CHANNEL]; - } - if (self.feature) { - [coder encodeObject:self.feature forKey:BRANCH_REQUEST_KEY_URL_FEATURE]; - } - if (self.stage) { - [coder encodeObject:self.stage forKey:BRANCH_REQUEST_KEY_URL_STAGE]; - } - if (self.campaign) { - [coder encodeObject:self.campaign forKey:BRANCH_REQUEST_KEY_URL_CAMPAIGN]; - } - if (self.params) { - NSString *encodedParams = [BNCEncodingUtils encodeDictionaryToJsonString:self.params]; - [coder encodeObject:encodedParams forKey:BRANCH_REQUEST_KEY_URL_DATA]; - } - if (self.duration > 0) { - [coder encodeObject:@(self.duration) forKey:BRANCH_REQUEST_KEY_URL_DURATION]; - } -} - -- (id)initWithCoder:(NSCoder *)coder { - if ((self = [super init])) { - self.tags = [coder decodeObjectOfClass:NSArray.class forKey:BRANCH_REQUEST_KEY_URL_TAGS]; - self.alias = [coder decodeObjectOfClass:NSString.class forKey:BRANCH_REQUEST_KEY_URL_ALIAS]; - self.type = [[coder decodeObjectOfClass:NSNumber.class forKey:BRANCH_REQUEST_KEY_URL_LINK_TYPE] integerValue]; - self.channel = [coder decodeObjectOfClass:NSString.class forKey:BRANCH_REQUEST_KEY_URL_CHANNEL]; - self.feature = [coder decodeObjectOfClass:NSString.class forKey:BRANCH_REQUEST_KEY_URL_FEATURE]; - self.stage = [coder decodeObjectOfClass:NSString.class forKey:BRANCH_REQUEST_KEY_URL_STAGE]; - self.campaign = [coder decodeObjectOfClass:NSString.class forKey:BRANCH_REQUEST_KEY_URL_CAMPAIGN]; - self.duration = [[coder decodeObjectOfClass:NSNumber.class forKey:BRANCH_REQUEST_KEY_URL_DURATION] integerValue]; - - NSString *encodedParams = [coder decodeObjectOfClass:NSString.class forKey:BRANCH_REQUEST_KEY_URL_DATA]; - self.params = [BNCEncodingUtils decodeJsonStringToDictionary:encodedParams]; - } - - return self; -} - -+ (BOOL)supportsSecureCoding { - return YES; -} @end diff --git a/Sources/BranchSDK/BNCServerRequest.m b/Sources/BranchSDK/BNCServerRequest.m index d17675581..799034ba7 100644 --- a/Sources/BranchSDK/BNCServerRequest.m +++ b/Sources/BranchSDK/BNCServerRequest.m @@ -29,19 +29,6 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error { [[BranchLogger shared] logError:@"BNCServerRequest subclasses must implement processResponse:error:." error:nil]; } -- (id)initWithCoder:(NSCoder *)aDecoder { - self = [super init]; - if (self) { - self.requestUUID = [aDecoder decodeObjectOfClass:NSString.class forKey:@"requestUUID"]; - self.requestCreationTimeStamp = [aDecoder decodeObjectOfClass:NSNumber.class forKey:@"requestCreationTimeStamp"]; - } - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [coder encodeObject:self.requestUUID forKey:@"requestUUID"]; - [coder encodeObject:self.requestCreationTimeStamp forKey:@"requestCreationTimeStamp"]; -} - (void)safeSetValue:(NSObject *)value forKey:(NSString *)key onDict:(NSMutableDictionary *)dict { if (value) { @@ -49,10 +36,6 @@ - (void)safeSetValue:(NSObject *)value forKey:(NSString *)key onDict:(NSMutableD } } -+ (BOOL)supportsSecureCoding { - return YES; -} - + (NSString *) generateRequestUUIDFromDate:(NSDate *) localDate { NSString *uuid = [[NSUUID UUID ] UUIDString]; diff --git a/Sources/BranchSDK/BNCServerRequestQueue.m b/Sources/BranchSDK/BNCServerRequestQueue.m index 2147f0fe8..370c8c5d2 100755 --- a/Sources/BranchSDK/BNCServerRequestQueue.m +++ b/Sources/BranchSDK/BNCServerRequestQueue.m @@ -19,7 +19,6 @@ static NSString * const BRANCH_QUEUE_FILE = @"BNCServerRequestQueue"; -static NSTimeInterval const BATCH_WRITE_TIMEOUT = 3.0; static inline uint64_t BNCNanoSecondsFromTimeInterval(NSTimeInterval interval) { @@ -29,8 +28,6 @@ static inline uint64_t BNCNanoSecondsFromTimeInterval(NSTimeInterval interval) { @interface BNCServerRequestQueue() @property (strong, nonatomic) NSMutableArray *queue; -@property (strong, nonatomic) dispatch_queue_t asyncQueue; -@property (strong, nonatomic) dispatch_source_t persistTimer; @end @@ -41,27 +38,14 @@ - (instancetype)init { if (!self) return self; self.queue = [NSMutableArray new]; - self.asyncQueue = dispatch_queue_create("io.branch.persist_queue", DISPATCH_QUEUE_SERIAL); - self.processArchivedOpens = YES; return self; } -- (void)dealloc { - @synchronized (self) { - if (self.persistTimer) { - dispatch_source_cancel(self.persistTimer); - self.persistTimer = nil; - } - [self persistImmediately]; - self.queue = nil; - } -} - (void)enqueue:(BNCServerRequest *)request { @synchronized (self) { if (request) { [self.queue addObject:request]; - [self persistEventually]; } } } @@ -74,7 +58,6 @@ - (void)insert:(BNCServerRequest *)request at:(NSUInteger)index { } if (request) { [self.queue insertObject:request atIndex:index]; - [self persistEventually]; } } } @@ -85,7 +68,6 @@ - (BNCServerRequest *)dequeue { if (self.queue.count > 0) { request = [self.queue objectAtIndex:0]; [self.queue removeObjectAtIndex:0]; - [self persistEventually]; } return request; } @@ -100,7 +82,6 @@ - (BNCServerRequest *)removeAt:(NSUInteger)index { } request = [self.queue objectAtIndex:index]; [self.queue removeObjectAtIndex:index]; - [self persistEventually]; return request; } } @@ -108,7 +89,6 @@ - (BNCServerRequest *)removeAt:(NSUInteger)index { - (void)remove:(BNCServerRequest *)request { @synchronized (self) { [self.queue removeObject:request]; - [self persistEventually]; } } @@ -145,7 +125,6 @@ - (NSString *)description { - (void)clearQueue { @synchronized (self) { [self.queue removeAllObjects]; - [self persistImmediately]; } } @@ -179,224 +158,11 @@ - (BranchOpenRequest *)findExistingInstallOrOpen { #pragma mark - Private Methods -- (void)persistEventually { - @synchronized (self) { - if (self.persistTimer) return; - - self.persistTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, self.asyncQueue); - if (!self.persistTimer) return; - - dispatch_time_t startTime = dispatch_time(DISPATCH_TIME_NOW, BNCNanoSecondsFromTimeInterval(BATCH_WRITE_TIMEOUT)); - dispatch_source_set_timer( - self.persistTimer, - startTime, - BNCNanoSecondsFromTimeInterval(BATCH_WRITE_TIMEOUT), - BNCNanoSecondsFromTimeInterval(BATCH_WRITE_TIMEOUT / 10.0) - ); - __weak __typeof(self) weakSelf = self; - dispatch_source_set_event_handler(self.persistTimer, ^ { - __strong __typeof(weakSelf) strongSelf = weakSelf; - if (strongSelf) { - [strongSelf cancelTimer]; - [strongSelf persistImmediately]; - } - }); - dispatch_resume(self.persistTimer); - } -} - -- (void)cancelTimer { - @synchronized (self) { - if (self.persistTimer) { - dispatch_source_cancel(self.persistTimer); - self.persistTimer = nil; - } - } -} - -- (void)persistImmediately { - @synchronized (self) { - if (!self.queue || self.queue.count == 0) { - return; - } - NSArray *queueCopy = [self.queue copy]; - - // encode the list of encoded request objects - NSData *data = [self archiveQueue:queueCopy]; - if (data) { - NSError *error = nil; - [data writeToURL:self.class.URLForQueueFile options:NSDataWritingAtomic error:&error]; - - if (error) { - [[BranchLogger shared] logError:[NSString stringWithFormat:@"Failed to persist queue to disk: %@.", error] error:error]; - } - } else { - [[BranchLogger shared] logError:[NSString stringWithFormat:@"Failed to encode queue."] error:nil]; - } - } -} - -// assumes queue no longer mutable -- (NSData *)archiveQueue:(NSArray *)queue { - NSMutableArray *archivedRequests = [NSMutableArray new]; - NSSet *requestClasses = [BNCServerRequestQueue replayableRequestClasses]; - for (BNCServerRequest *request in queue) { - - // only persist analytics requests, skip the rest - if ([requestClasses containsObject:request.class]) { - [archivedRequests addObject:request]; - } - } - return [self archiveObject:archivedRequests]; -} - -// For testing backwards compatibility -// The old version did a double archive and didn't filter replayable requests -- (NSData *)oldArchiveQueue:(NSArray *)queue { - NSMutableArray *archivedRequests = [NSMutableArray new]; - for (BNCServerRequest *request in queue) { - - // archive every request - NSData *encodedRequest = [self archiveObject:request]; - [archivedRequests addObject:encodedRequest]; - } - return [self archiveObject:archivedRequests]; -} - -- (NSData *)archiveObject:(NSObject *)object { - NSData *data = nil; - NSError *error = nil; - data = [NSKeyedArchiver archivedDataWithRootObject:object requiringSecureCoding:YES error:&error]; - - if (!data && error) { - [[BranchLogger shared] logWarning:@"Failed to archive: %@" error:error]; - } - return data; -} - -// Loads saved requests from disk. Only called on app start. -- (void)retrieve { - @synchronized (self) { - NSError *error = nil; - NSData *data = [NSData dataWithContentsOfURL:self.class.URLForQueueFile options:0 error:&error]; - if (!error && data) { - NSMutableArray *decodedQueue = [self unarchiveQueueFromData:data]; - for (id request in decodedQueue) { - if ([request isKindOfClass:[BranchOpenRequest class]] || [request isKindOfClass:[BranchInstallRequest class]]) { - ((BranchOpenRequest *)request).isFromArchivedQueue = YES; - } - } - self.queue = decodedQueue; - // Requests are loaded into queue now. Delete queue file stored on disk. - [self removeSaveFile]; - } - } -} - -// It's been reported that unarchive can fail in some situations. In that case, remove the queued requests file. -- (void)removeSaveFile { - NSURL *fileURL = [BNCServerRequestQueue URLForQueueFile]; - if (fileURL) { - NSError *error; - [NSFileManager.defaultManager removeItemAtURL:fileURL error:&error]; - - if (error) { - [[BranchLogger shared] logError:@"Failed to remove archived queue" error:error]; - } - } -} - -- (NSMutableArray *)unarchiveQueueFromData:(NSData *)data { - NSMutableArray *queue = [NSMutableArray new]; - - NSArray *requestArray = nil; - id tmp = [self unarchiveObjectFromData:data]; - if ([tmp isKindOfClass:[NSArray class]]) { - requestArray = (NSArray *)tmp; - } - - // validate request array - // There should never be an object that is not a replayable class or NSData - for (id request in requestArray) { - id tmpRequest = request; - - // handle legacy NSData - if ([request isKindOfClass:[NSData class]]) { - tmpRequest = [self unarchiveObjectFromData:request]; - } - - // make sure we didn't unarchive something unexpected - if ([[BNCServerRequestQueue replayableRequestClasses] containsObject:[tmpRequest class]]) { - [queue addObject:tmpRequest]; - } - } - - return queue; -} - -- (id)unarchiveObjectFromData:(NSData *)data { - NSError *error; - id object = [NSKeyedUnarchiver unarchivedObjectOfClasses:[BNCServerRequestQueue encodableClasses] fromData:data error:&error]; - - if (error) { - [[BranchLogger shared] logError:@"Failed to unarchive" error:error]; - [self removeSaveFile]; - } - - return object; -} - -// only replay analytics requests, the others are time sensitive -+ (NSSet *)replayableRequestClasses { - static NSSet *requestClasses = nil; - static dispatch_once_t onceToken = 0; - dispatch_once(&onceToken, ^ { - NSArray *tmp = @[ - [BranchOpenRequest class], - [BranchInstallRequest class], - [BranchEventRequest class] - ]; - requestClasses = [NSSet setWithArray:tmp]; - }); - - return requestClasses; -} - -// encodable classes also includes NSArray and NSData -+ (NSSet *)encodableClasses { - static NSSet *classes = nil; - static dispatch_once_t onceToken = 0; - dispatch_once(&onceToken, ^ { - NSMutableArray *tmp = [NSMutableArray new]; - [tmp addObject:[NSArray class]]; // root object - [tmp addObject:[NSData class]]; // legacy format compatibility - - // add all replayable request objects - [tmp addObjectsFromArray: [[BNCServerRequestQueue replayableRequestClasses] allObjects]]; - - classes = [NSSet setWithArray:tmp]; - }); - - return classes; -} - -+ (NSURL * _Nonnull) URLForQueueFile { - static NSURL *URL = nil; - static dispatch_once_t onceToken = 0; - dispatch_once(&onceToken, ^ { - URL = BNCURLForBranchDirectory(); - URL = [URL URLByAppendingPathComponent:BRANCH_QUEUE_FILE isDirectory:NO]; - }); - return URL; -} - + (instancetype)getInstance { static BNCServerRequestQueue *sharedQueue = nil; static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^ { sharedQueue = [[BNCServerRequestQueue alloc] init]; - [sharedQueue retrieve]; - [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Retrieved from storage: %@.", sharedQueue] error:nil]; }); return sharedQueue; } diff --git a/Sources/BranchSDK/Branch.m b/Sources/BranchSDK/Branch.m index 9b4d4f87e..734c5d226 100644 --- a/Sources/BranchSDK/Branch.m +++ b/Sources/BranchSDK/Branch.m @@ -1725,7 +1725,7 @@ - (void)applicationDidBecomeActive { [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"applicationDidBecomeActive installOrOpenInQueue %d", installOrOpenInQueue] error:nil]; if (!Branch.trackingDisabled && self.initializationStatus != BNCInitStatusInitialized && !installOrOpenInQueue) { - [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"applicationDidBecomeActive trackingDisabled %d initializationStatus %d installOrOpenInQueue %d", Branch.trackingDisabled, self.initializationStatus, installOrOpenInQueue] error:nil]; + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"applicationDidBecomeActive trackingDisabled %d initializationStatus %ld installOrOpenInQueue %d", Branch.trackingDisabled, (long)self.initializationStatus, installOrOpenInQueue] error:nil]; [self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:nil reset:NO]; } @@ -1740,7 +1740,6 @@ - (void)applicationWillResignActive { self.initializationStatus = BNCInitStatusUninitialized; [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"applicationWillResignActive initializationStatus %ld", self.initializationStatus] error:nil]; - [self.requestQueue persistImmediately]; [BranchOpenRequest setWaitNeededForOpenResponseLock]; } }); @@ -1897,15 +1896,6 @@ - (void)processNextQueueItem { } } - if ( !(((BNCServerRequestQueue*)[BNCServerRequestQueue getInstance]).processArchivedOpens) - && [req isKindOfClass:[BranchOpenRequest class]] - && ((BranchOpenRequest *)req).isFromArchivedQueue){ - [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Removed Archived Open Request from Queue %@", [req description]] error:nil]; - [self.requestQueue remove:req]; - self.networkCount = 0; - [self processNextQueueItem]; - return; - } dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(queue, ^ { diff --git a/Sources/BranchSDK/BranchEvent.m b/Sources/BranchSDK/BranchEvent.m index b16c813f8..c4c651dfc 100644 --- a/Sources/BranchSDK/BranchEvent.m +++ b/Sources/BranchSDK/BranchEvent.m @@ -128,30 +128,6 @@ - (void)processResponse:(BNCServerResponse*)response error:(NSError*)error { } } -#pragma mark BranchEventRequest NSSecureCoding - -- (instancetype)initWithCoder:(NSCoder *)decoder { - self = [super initWithCoder:decoder]; - if (!self) return self; - - self.serverURL = [decoder decodeObjectOfClass:NSURL.class forKey:@"serverURL"]; - - NSSet *classes = [NSSet setWithArray:@[NSDictionary.class, NSArray.class, NSString.class, NSNumber.class]]; - self.eventDictionary = [decoder decodeObjectOfClasses:classes forKey:@"eventDictionary"]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - [coder encodeObject:self.serverURL forKey:@"serverURL"]; - [coder encodeObject:self.eventDictionary forKey:@"eventDictionary"]; -} - -+ (BOOL)supportsSecureCoding { - return YES; -} - @end #pragma mark - BranchEvent diff --git a/Sources/BranchSDK/BranchOpenRequest.m b/Sources/BranchSDK/BranchOpenRequest.m index a05c5bf47..fd67c3da8 100644 --- a/Sources/BranchSDK/BranchOpenRequest.m +++ b/Sources/BranchSDK/BranchOpenRequest.m @@ -153,9 +153,6 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error { } } - if (referringURL.length > 0) { - ((BNCServerRequestQueue *)[BNCServerRequestQueue getInstance]).processArchivedOpens = NO; - } // Clear link identifiers so they don't get reused on the next open preferenceHelper.linkClickIdentifier = nil; @@ -258,21 +255,6 @@ - (NSString *)getActionName { return @"open"; } -- (instancetype)initWithCoder:(NSCoder *)decoder { - self = [super initWithCoder:decoder]; - if (!self) return self; - self.urlString = [decoder decodeObjectOfClass:NSString.class forKey:@"urlString"]; - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - [coder encodeObject:self.urlString forKey:@"urlString"]; -} - -+ (BOOL)supportsSecureCoding { - return YES; -} #pragma - Open Response Lock Handling diff --git a/Sources/BranchSDK/BranchShortUrlRequest.m b/Sources/BranchSDK/BranchShortUrlRequest.m index 90f41dd5c..d1198acde 100644 --- a/Sources/BranchSDK/BranchShortUrlRequest.m +++ b/Sources/BranchSDK/BranchShortUrlRequest.m @@ -132,51 +132,4 @@ - (NSString *)createLongUrlForUserUrl:(NSString *)userUrl { return longUrl; } -#pragma mark - NSCoding methods - -- (id)initWithCoder:(NSCoder *)decoder { - if ((self = [super initWithCoder:decoder])) { - _tags = [decoder decodeObjectOfClass:NSArray.class forKey:@"tags"]; - _alias = [decoder decodeObjectOfClass:NSString.class forKey:@"alias"]; - _type = [decoder decodeIntegerForKey:@"type"]; - _matchDuration = [decoder decodeIntegerForKey:@"duration"]; - _channel = [decoder decodeObjectOfClass:NSString.class forKey:@"channel"]; - _feature = [decoder decodeObjectOfClass:NSString.class forKey:@"feature"]; - _stage = [decoder decodeObjectOfClass:NSString.class forKey:@"stage"]; - _campaign = [decoder decodeObjectOfClass:NSString.class forKey:@"campaign"]; - _params = [BNCEncodingUtils decodeJsonStringToDictionary: - [decoder decodeObjectOfClass:NSString.class forKey:@"params"]]; - - // Set up link data - self.linkData = [[BNCLinkData alloc] init]; - [self.linkData setupType:_type]; - [self.linkData setupTags:_tags]; - [self.linkData setupChannel:_channel]; - [self.linkData setupFeature:_feature]; - [self.linkData setupStage:_stage]; - [self.linkData setupCampaign:_campaign]; - [self.linkData setupAlias:_alias]; - [self.linkData setupMatchDuration:_matchDuration]; - [self.linkData setupParams:_params]; - } - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - [coder encodeObject:self.tags forKey:@"tags"]; - [coder encodeObject:self.alias forKey:@"alias"]; - [coder encodeInteger:self.type forKey:@"type"]; - [coder encodeInteger:self.matchDuration forKey:@"duration"]; - [coder encodeObject:self.channel forKey:@"channel"]; - [coder encodeObject:self.feature forKey:@"feature"]; - [coder encodeObject:self.stage forKey:@"stage"]; - [coder encodeObject:self.campaign forKey:@"campaign"]; - [coder encodeObject:[BNCEncodingUtils encodeDictionaryToJsonString:self.params] forKey:@"params"]; -} - -+ (BOOL)supportsSecureCoding { - return YES; -} - @end diff --git a/Sources/BranchSDK/Public/BNCLinkData.h b/Sources/BranchSDK/Public/BNCLinkData.h index c092409bc..d2488702c 100644 --- a/Sources/BranchSDK/Public/BNCLinkData.h +++ b/Sources/BranchSDK/Public/BNCLinkData.h @@ -17,7 +17,7 @@ typedef NS_ENUM(NSUInteger, BranchLinkType) { BranchLinkTypeOneTimeUse = 1 }; -@interface BNCLinkData : NSObject +@interface BNCLinkData : NSObject @property (strong, nonatomic) NSMutableDictionary *data; diff --git a/Sources/BranchSDK/Public/BNCServerRequest.h b/Sources/BranchSDK/Public/BNCServerRequest.h index 9b65ff53c..2b4972887 100644 --- a/Sources/BranchSDK/Public/BNCServerRequest.h +++ b/Sources/BranchSDK/Public/BNCServerRequest.h @@ -8,7 +8,7 @@ #import "BNCServerInterface.h" -@interface BNCServerRequest : NSObject +@interface BNCServerRequest : NSObject @property (nonatomic, copy, readwrite) NSString *requestUUID; @property (nonatomic, copy, readwrite) NSNumber *requestCreationTimeStamp; diff --git a/Sources/BranchSDK/Public/BNCServerRequestQueue.h b/Sources/BranchSDK/Public/BNCServerRequestQueue.h index 311c65a76..1c9d9391f 100755 --- a/Sources/BranchSDK/Public/BNCServerRequestQueue.h +++ b/Sources/BranchSDK/Public/BNCServerRequestQueue.h @@ -11,8 +11,6 @@ @interface BNCServerRequestQueue : NSObject -@property (assign, nonatomic) BOOL processArchivedOpens; - - (void)enqueue:(BNCServerRequest *)request; - (BNCServerRequest *)dequeue; - (BNCServerRequest *)peek; @@ -27,8 +25,5 @@ - (BranchOpenRequest *)findExistingInstallOrOpen; -- (void)persistEventually; -- (void)persistImmediately; - + (id)getInstance; @end diff --git a/Sources/BranchSDK/Public/BranchEvent.h b/Sources/BranchSDK/Public/BranchEvent.h index 484fb529e..489d8c38b 100644 --- a/Sources/BranchSDK/Public/BranchEvent.h +++ b/Sources/BranchSDK/Public/BranchEvent.h @@ -120,7 +120,7 @@ typedef NS_ENUM(NSInteger, BranchEventAdType) { #pragma mark - BranchEventRequest -@interface BranchEventRequest : BNCServerRequest +@interface BranchEventRequest : BNCServerRequest - (instancetype _Nonnull) initWithServerURL:(NSURL*_Nonnull)serverURL eventDictionary:(NSDictionary*_Nullable)eventDictionary