From 4604b370f974e5c955aad57c2c046af0218a277c Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 29 Mar 2024 13:44:11 -0700 Subject: [PATCH] Fix serialization of install/open for 3.3. This only impacts error handling. --- .../Branch-SDK-Tests/BNCClassSerializationTests.m | 11 +++++++---- Sources/BranchSDK/BranchOpenRequest.m | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Branch-TestBed/Branch-SDK-Tests/BNCClassSerializationTests.m b/Branch-TestBed/Branch-SDK-Tests/BNCClassSerializationTests.m index 501e17e4f..f1af287d9 100644 --- a/Branch-TestBed/Branch-SDK-Tests/BNCClassSerializationTests.m +++ b/Branch-TestBed/Branch-SDK-Tests/BNCClassSerializationTests.m @@ -16,6 +16,10 @@ @interface BranchEvent() - (NSDictionary *)buildEventDictionary; @end +@interface BranchOpenRequest() +- (NSString *)getActionName; +@end + @interface BNCClassSerializationTests : XCTestCase @end @@ -84,9 +88,9 @@ - (void)testBranchOpenRequestArchive { XCTAssertTrue([object isKindOfClass:BranchOpenRequest.class]); BranchOpenRequest *unarchivedRequest = (BranchOpenRequest *)object; - // Should the urlString be restored? Probably not. - //XCTAssertTrue([request.urlString isEqualToString:unarchivedRequest.urlString]); + XCTAssertTrue([request.urlString isEqualToString:unarchivedRequest.urlString]); XCTAssertNil(unarchivedRequest.callback); + XCTAssertTrue([@"open" isEqualToString:[unarchivedRequest getActionName]]); } - (void)testBranchInstallRequestArchive { @@ -108,8 +112,7 @@ - (void)testBranchInstallRequestArchive { XCTAssertTrue([object isKindOfClass:BranchInstallRequest.class]); BranchInstallRequest *unarchivedRequest = (BranchInstallRequest *)object; - // Should the urlString be restored? Probably not. - //XCTAssertTrue([request.urlString isEqualToString:unarchivedRequest.urlString]); + XCTAssertTrue([request.urlString isEqualToString:unarchivedRequest.urlString]); XCTAssertNil(unarchivedRequest.callback); XCTAssertTrue([@"install" isEqualToString:[unarchivedRequest getActionName]]); } diff --git a/Sources/BranchSDK/BranchOpenRequest.m b/Sources/BranchSDK/BranchOpenRequest.m index d7c23af8e..38533f8fe 100644 --- a/Sources/BranchSDK/BranchOpenRequest.m +++ b/Sources/BranchSDK/BranchOpenRequest.m @@ -253,6 +253,21 @@ - (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