Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
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 retrival is
// success or failure, we don't want to do the retrival again on next app start.
// If we try to redo the retrival again because of some error, the user will experiance 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