Skip to content

Commit

Permalink
Fix serialization of install/open for 3.3. This only impacts error ha…
Browse files Browse the repository at this point in the history
…ndling.
  • Loading branch information
echo-branch committed Mar 29, 2024
1 parent b15b22f commit 4604b37
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Branch-TestBed/Branch-SDK-Tests/BNCClassSerializationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ @interface BranchEvent()
- (NSDictionary *)buildEventDictionary;
@end

@interface BranchOpenRequest()
- (NSString *)getActionName;
@end

@interface BNCClassSerializationTests : XCTestCase

@end
Expand Down Expand Up @@ -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 {
Expand All @@ -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]]);
}
Expand Down
15 changes: 15 additions & 0 deletions Sources/BranchSDK/BranchOpenRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4604b37

Please sign in to comment.