From 0428460ebb4a911506849e8cdefe97f5f686e3fd Mon Sep 17 00:00:00 2001 From: Mike Hardy Date: Wed, 25 May 2022 20:06:19 -0500 Subject: [PATCH] feat(dynamic-links, ios): performDiagnostics API for troubleshooting --- docs/dynamic-links/usage/index.md | 2 ++ packages/dynamic-links/e2e/dynamicLinks.e2e.js | 6 ++++++ .../ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m | 2 ++ packages/dynamic-links/lib/index.d.ts | 9 +++++++++ packages/dynamic-links/lib/index.js | 9 +++++++++ 5 files changed, 28 insertions(+) diff --git a/docs/dynamic-links/usage/index.md b/docs/dynamic-links/usage/index.md index d75a6f839d..e4b6b20f7a 100644 --- a/docs/dynamic-links/usage/index.md +++ b/docs/dynamic-links/usage/index.md @@ -135,6 +135,8 @@ The iOS Notes app is a good place to paste your dynamic link and test it opens y 6. Make sure your [deep link parameter](https://firebase.google.com/docs/dynamic-links/create-manually?authuser=0#parameters) is properly URL-encoded, especially if it contains a query string. +7. Try the `performDiagnostics` API on the Dynamic Links module, while running the app on a real device and watching output from either Xcode or Console app. You may search for "Links" and you will see the diagnostic output. + ## Android Setup 1. Create a SHA-256 fingerprint using these [instructions](https://developers.google.com/android/guides/client-auth) for your app, and add to your app in your Firebase console. diff --git a/packages/dynamic-links/e2e/dynamicLinks.e2e.js b/packages/dynamic-links/e2e/dynamicLinks.e2e.js index 22c2949ff3..16aad63e58 100644 --- a/packages/dynamic-links/e2e/dynamicLinks.e2e.js +++ b/packages/dynamic-links/e2e/dynamicLinks.e2e.js @@ -237,4 +237,10 @@ describe('dynamicLinks()', function () { } }); }); + + describe('performDiagnostics()', function () { + it('should perform diagnostics without error', async function () { + firebase.dynamicLinks().performDiagnostics(); + }); + }); }); diff --git a/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m b/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m index 31c1cbf119..17aff6c164 100644 --- a/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m +++ b/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m @@ -228,6 +228,8 @@ - (id)init { } } +RCT_EXPORT_METHOD(performDiagnostics) { [FIRDynamicLinks performDiagnosticsWithCompletion:nil]; } + RCT_EXPORT_METHOD(resolveLink : (NSString *)link : (RCTPromiseResolveBlock)resolve diff --git a/packages/dynamic-links/lib/index.d.ts b/packages/dynamic-links/lib/index.d.ts index bc80274c8e..2f13c96e79 100644 --- a/packages/dynamic-links/lib/index.d.ts +++ b/packages/dynamic-links/lib/index.d.ts @@ -549,6 +549,15 @@ export namespace FirebaseDynamicLinksTypes { */ onLink(listener: (link: DynamicLink) => void): () => void; + /** + * Perform built-in diagnostics on iOS. This is best performed on a real device running + * a build from Xcode so you may see the output easily. Alternatively it should be visible + * in Console.app with an iPhone plugged into a macOS computer + * + * NOTE: iOS only + */ + performDiagnostics(): void; + /** * Resolve a given dynamic link (short or long) directly. * diff --git a/packages/dynamic-links/lib/index.js b/packages/dynamic-links/lib/index.js index 050e3d426d..437edfbf63 100644 --- a/packages/dynamic-links/lib/index.js +++ b/packages/dynamic-links/lib/index.js @@ -20,6 +20,7 @@ import { FirebaseModule, getFirebaseRoot, } from '@react-native-firebase/app/lib/internal'; +import { isIOS } from '@react-native-firebase/app/lib/common'; import builder from './builder'; import version from './version'; @@ -86,6 +87,14 @@ class FirebaseLinksModule extends FirebaseModule { }; } + performDiagnostics() { + if (isIOS) { + return this.native.performDiagnostics(); + } + + Promise.resolve(); + } + resolveLink(link) { if (!link) { throw new Error('firebase.dynamicLinks().resolve(*) Invalid link parameter');