Skip to content

Commit

Permalink
Fixing unwanted pending dynamic links checks on subsequent app restar…
Browse files Browse the repository at this point in the history
…ts (#5665)

* Fix for internal bug b/154589338

Most of the times, when the app is cold started, we are making api calls to:

https://firebasedynamiclinks-ipv4.googleapis.com/v1
https://firebasedynamiclinks-ipv6.googleapis.com/v1

Until we get a successful response. But sometimes, if the device doesn’t have support for v6 endpoint and if the v4 endpoint doesn’t retrieve a valid dynamic link, it will return error. This mostly happens when user directly goes to App Store and installs an app which has fdl sdk integrated.

For dynamic links, we want the app to retrieve the pending dynamic link on the very first start of the app after install so that 3p developers can deeplink to a particular page in the app. If the pending links retrieval failed during the first start, there is no point in retrying the retrieval during next restart since it could result in an un expected  deep link for the user when they opens up the app for subsequent restarts (if a valid dynamic link is returned).
  • Loading branch information
eldhosembabu authored May 29, 2020
1 parent 45eeb54 commit 68b0a23
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
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
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 comments on commit 68b0a23

Please sign in to comment.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy