8000 Fixing unwanted pending dynamic links checks on subsequent app restarts by eldhosembabu · Pull Request #5665 · firebase/firebase-ios-sdk · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions FirebaseDynamicLinks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
- [fixed] Fixing unwanted pending dynamic links checks on subsequent app restarts

# v4.0.8 -- M67
- [fixed] Fix Catalyst build - removed deprecated unused Apple framework dependencies. (#5139)

Expand Down
< 8000 /deferred-diff-lines>
7 changes: 6 additions & 1 deletion FirebaseDynamicLinks/Sources/FIRDynamicLinks.m
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,14 @@ - (void)retrievalProcess:(id<FIRDLRetrievalProcessProtocol>)retrievalProcess
self.retrievingPendingDynamicLink = NO;
_retrievalProcess = nil;

if (!result.error && ![_userDefaults boolForKey:kFIRDLOpenURLKey]) {
if (![_userDefaults boolForKey:kFIRDLOpenURLKey]) {
// Once we complete the Pending dynamic link retrieval, regardless of whether the retrieval is
// success or failure, we don't want to do the retrieval again on next app start.
// If we try to redo the retrieval again because of some error, the user will experience
// unwanted deeplinking when they restart the app next time.
[_userDefaults setBool:YES forKey:kFIRDLOpenURLKey];
}

NSURL *linkToPassToApp = [result URLWithCustomURLScheme:_URLScheme];
[self passRetrievedDynamicLinkToApplication:linkToPassToApp];
}
Expand Down
26 changes: 26 additions & 0 deletions FirebaseDynamicLinks/Tests/Unit/FIRDynamicLinksTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#import <GoogleUtilities/GULSwizzler+Unswizzle.h>
#import <GoogleUtilities/GULSwizzler.h>
#import <OCMock/OCMock.h>
#import "FirebaseDynamicLinks/Sources/FIRDLDefaultRetrievalProcessV2.h"
#import "FirebaseDynamicLinks/Sources/FIRDLRetrievalProcessFactory.h"
#import "FirebaseDynamicLinks/Sources/FIRDLRetrievalProcessResult+Private.h"
#import "FirebaseDynamicLinks/Sources/FIRDynamicLink+Private.h"
Expand Down Expand Up @@ -1171,6 +1172,31 @@ - (void)test_multipleRequestsToRetrievePendingDeepLinkShouldNotCrash {
isClassSelector:NO];
}

- (void)test_retrievePendingDeepLinkShouldSetkFIRDLOpenURLKeyRegardlessOfFailures {
[self.service setUpWithLaunchOptions:nil
apiKey:kAPIKey
clientID:kClientID
urlScheme:nil
userDefaults:[NSUserDefaults standardUserDefaults]];
FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *deleagte =
(FIRDynamicLinks<FIRDLRetrievalProcessDelegate> *)self.service;

// Error Result to pass
FIRDLRetrievalProcessResult *result = [[FIRDLRetrievalProcessResult alloc]
initWithDynamicLink:nil
error:[NSError errorWithDomain:@"unknown domain" code:500 userInfo:nil]
message:nil
matchSource:nil];

FIRDLDefaultRetrievalProcessV2 *defaultRetrievalProcess = [FIRDLDefaultRetrievalProcessV2 alloc];

[deleagte retrievalProcess:defaultRetrievalProcess completedWithResult:result];

NSString *kFIRDLOpenURLKey = @"com.google.appinvite.openURL";
XCTAssertEqual([[NSUserDefaults standardUserDefaults] boolForKey:kFIRDLOpenURLKey], YES,
@"kFIRDLOpenURL key should be set regardless of failures");
}

#pragma mark - Self-diagnose tests

- (void)testSelfDiagnoseWithNilCompletion {
Expand Down
0