From f10658e11aaae9a5b1b2566c05a0a62c46a00522 Mon Sep 17 00:00:00 2001 From: Melvyn Hills Date: Sun, 5 Jul 2020 22:44:23 +0200 Subject: [PATCH] fix(dynamic-links,ios): resolveLink() does not always resolve (#3870) [publish] Co-authored-by: Mike Hardy --- packages/dynamic-links/e2e/dynamicLinks.e2e.js | 11 +++++++++++ .../ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m | 10 ++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/dynamic-links/e2e/dynamicLinks.e2e.js b/packages/dynamic-links/e2e/dynamicLinks.e2e.js index a35d2a0e9b..730339f453 100644 --- a/packages/dynamic-links/e2e/dynamicLinks.e2e.js +++ b/packages/dynamic-links/e2e/dynamicLinks.e2e.js @@ -24,6 +24,7 @@ const TEST_LINK = 'https://reactnativefirebase.page.link/?link=https://rnfirebase.io&apn=com.invertase.testing'; const TEST_LINK2 = 'https://reactnativefirebase.page.link/?link=https://invertase.io/hire-us&apn=com.invertase.testing'; +const TEST_LINK3 = 'https://invertase.io'; module.exports.baseParams = baseParams; @@ -127,6 +128,16 @@ describe('dynamicLinks()', () => { } }); + it('throws on static links', async () => { + try { + await firebase.dynamicLinks().resolveLink(TEST_LINK3); + return Promise.reject(new Error('Did not throw Error.')); + } catch (e) { + e.message.should.containEql('Dynamic link not found'); + return Promise.resolve(); + } + }); + it('throws on invalid links', async () => { try { await firebase.dynamicLinks().resolveLink(null); diff --git a/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m b/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m index 4fbdda462c..6e08dec952 100644 --- a/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m +++ b/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m @@ -204,10 +204,16 @@ - (id)init { @"message":[error localizedDescription] }]; } -}; + }; NSURL *linkURL = [NSURL URLWithString:link]; - [[FIRDynamicLinks dynamicLinks] handleUniversalLink:linkURL completion:completion]; + BOOL success = [[FIRDynamicLinks dynamicLinks] handleUniversalLink:linkURL completion:completion]; + if (!success) { + [RNFBSharedUtils rejectPromiseWithUserInfo:reject userInfo:(NSMutableDictionary *) @{ + @"code": @"not-found", + @"message": @"Dynamic link not found" + }]; + } } - (FIRDynamicLinkComponents *)createDynamicLinkComponents:(NSDictionary *)dynamicLinkDict {