Skip to content

Commit

Permalink
feat(dynamic-links, ios): performDiagnostics API for troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehardy committed May 26, 2022
1 parent 88e218e commit 0428460
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/dynamic-links/usage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions packages/dynamic-links/e2e/dynamicLinks.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,10 @@ describe('dynamicLinks()', function () {
}
});
});

describe('performDiagnostics()', function () {
it('should perform diagnostics without error', async function () {
firebase.dynamicLinks().performDiagnostics();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ - (id)init {
}
}

RCT_EXPORT_METHOD(performDiagnostics) { [FIRDynamicLinks performDiagnosticsWithCompletion:nil]; }

RCT_EXPORT_METHOD(resolveLink
: (NSString *)link
: (RCTPromiseResolveBlock)resolve
Expand Down
9 changes: 9 additions & 0 deletions packages/dynamic-links/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
9 changes: 9 additions & 0 deletions packages/dynamic-links/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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');
Expand Down

1 comment on commit 0428460

@vercel
Copy link

@vercel vercel bot commented on 0428460 May 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.