Skip to content

Commit 3ff4889

Browse files
authored
feat(dynamic-links): support short links on iOS (#163)
1 parent a4a5c45 commit 3ff4889

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/firebase-dynamic-links/index.ios.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,21 @@ export class DynamicLinks implements IDynamicLinks {
474474
}
475475

476476
buildLink(link: DynamicLinkParameters): Promise<string> {
477-
return new Promise((resolve, reject) => {
478-
resolve(link.native.url.absoluteString);
479-
});
477+
if (link.native.options) {
478+
// short link
479+
return new Promise((resolve, reject) => {
480+
link.native.shortenWithCompletion((url, warnings, error) => {
481+
if (error) {
482+
reject(FirebaseError.fromNative(error));
483+
} else {
484+
resolve(url.absoluteString);
485+
}
486+
});
487+
});
488+
} else {
489+
// long link
490+
return Promise.resolve(link.native.url.absoluteString);
491+
}
480492
}
481493

482494
onLink(listener: (link: DynamicLink) => void) {

0 commit comments

Comments
 (0)