Skip to content

Commit 7d52a81

Browse files
authored
Merge pull request #1003 from BranchMetrics/INTENG-8758-be-more-consistent-about-callback-thread
INTENG-8758 restore previous callback on main behavior
2 parents f54ec67 + 22f4b0b commit 7d52a81

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Branch-SDK/Branch-SDK/Branch.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,10 @@ - (void)generateShortUrl:(NSArray *)tags
15911591

15921592
if ([self.linkCache objectForKey:linkData]) {
15931593
if (callback) {
1594-
callback([self.linkCache objectForKey:linkData], nil);
1594+
// callback on main, this is generally what the client expects and maintains our previous behavior
1595+
dispatch_async(dispatch_get_main_queue(), ^ {
1596+
callback([self.linkCache objectForKey:linkData], nil);
1597+
});
15951598
}
15961599
return;
15971600
}
@@ -1774,7 +1777,12 @@ - (void)registerViewWithParams:(NSDictionary *)params andCallback:(callbackWithP
17741777
BranchUniversalObject *buo = [[BranchUniversalObject alloc] init];
17751778
buo.contentMetadata.customMetadata = (id) params;
17761779
[[BranchEvent standardEvent:BranchStandardEventViewItem withContentItem:buo] logEvent];
1777-
if (callback) callback(@{}, nil);
1780+
if (callback) {
1781+
// callback on main, this is generally what the client expects and maintains our previous behavior
1782+
dispatch_async(dispatch_get_main_queue(), ^ {
1783+
callback(@{}, nil);
1784+
});
1785+
}
17781786
});
17791787
}
17801788

0 commit comments

Comments
 (0)