🔥 [Dynamic Links][iOS] Unable to use custom domain with getInitialLink() or onLink()
Issue
Per the Firebase console and documentation, using custom domains with Dynamic Links is supported.
This allows the use of any verified domain to serve as a Dynamic Link prefix, e.g. https://go.my.app.
This appears to work out of the box on Android -- using links created by programmatically and manually via the console.
However, on iOS, I'm only able to successfully invoke onLink() and getInitialLink() when using the "default" style of prefix links, e.g. https://app_name.page.link.
I've referred to the Firebase documentation where relevant, such as following step 4 for iOS.
Scenario A: Using *.page.link dynamic link:
firebase.links().getInitialLink().then((url) => {
// returns dynamic link URL target
}
Scenario B: Using custom domain go.my.app dynamic link:
firebase.links().getInitialLink().then((url) => {
// returns undefined
}
When wrapped in a try/catch, I get no exceptions.
Any guidance on how to resolve this so we can use our branded short URL with iOS users is greatly appreciated!
Project Files
iOS
ios/Podfile:
- [ ] I'm not using Pods
- [x] I'm using Pods and my Podfile looks like:
...
pod 'Firebase/Core', '~> 5.15.0'
pod 'Firebase/Auth', '~> 5.15.0'
pod 'Firebase/Messaging', '~> 5.15.0'
pod 'Fabric', '~> 1.7.13'
pod 'Crashlytics', '~> 3.10.7'
pod 'Firebase/DynamicLinks', '~> 5.15.0'
pod 'Firebase/Performance', '~> 5.15.0'
...
AppDelegate.m:
#import "AppDelegate.h"
#import <Firebase.h>
#import "RNFirebaseLinks.h"
#import "RNFirebaseNotifications.h"
#import "RNFirebaseMessaging.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
static NSString *const CUSTOM_URL_SCHEME = @"[REDACTED]";
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
[FIROptions defaultOptions].deepLinkURLScheme = CUSTOM_URL_SCHEME;
[RNFirebaseNotifications configure];
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
[[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
[[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
if (!handled) {
handled = [[RNFirebaseLinks instance] application:application openURL:url options:options];
}
return handled;
}
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *))restorationHandler {
return [[RNFirebaseLinks instance] application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}
@end
Android
android/build.gradle:
// N/A
android/app/build.gradle:
// N/A
android/settings.gradle:
// N/A
MainApplication.java:
// N/A
AndroidManifest.xml:
<!-- N/A -->
Environment
- Platform that you're experiencing the issue on:
- [x] iOS
- [ ] Android
- [ ] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [ ] Both
- If known, the version of the platform are you experiencing the issue on:
- iOS 12.1 (simulator and physical device)
- Operating System:
- [x] MacOS, version:
10.14.3 - [x] Windows, version:
10.0.17763 - [ ] Other, please specify:
N/A
- [x] MacOS, version:
- Build Tools:
Xcode 10.1 (10B61), Android Studio 3.3.1
React Nativeversion:0.57.1 (Expo 32 Fork)
React Native Firebaselibrary version:5.2.3
Firebasemodule(s) you're using that has the issue:- [ ] N/A
- [ ] Authentication
- [ ] Analytics
- [ ] Cloud Firestore
- [ ] Cloud Messaging (FCM)
- [ ] Crashlytics
- [x] Dynamic Links
- [ ] Functions Callable
- [ ] In App Messaging
- [ ] Indexing
- [ ] Invites
- [ ] Instance ID
- [ ] ML Kit
- [ ] Notifications
- [ ] Performance Monitoring
- [ ] Realtime Database
- [ ] Remote Config
- [ ] Storage
- Are you using
TypeScript?- [x] No
- [ ] Yes, version:
N/A
- Are you using Expo, e.g.
ExpoKit?- [ ] No
- [ ] Yes, I've not ejected
- [x] Yes, but I have ejected to
ExpoKit - [ ] Yes, but I have ejected to vanilla React Native
- Expo version:
32
Could you please try changing the order of the following two lines:
[FIRApp configure];
[FIROptions defaultOptions].deepLinkURLScheme = CUSTOM_URL_SCHEME;
to be :
[FIROptions defaultOptions].deepLinkURLScheme = CUSTOM_URL_SCHEME;
[FIRApp configure];
Read point 5.2 https://rnfirebase.io/docs/v5.x.x/links/ios
[FIROptions defaultOptions].deepLinkURLScheme = CUSTOM_URL_SCHEME; [FIRApp configure];Read point 5.2 https://rnfirebase.io/docs/v5.x.x/links/ios
Appreciate the suggestion there, but even with resolution of that disarrangement on a new build, the original issue still persists -- custom domain dynamic links are nonfunctional.
We are having the same issue. Works with default example.page.link but not with custom dynamic links
I had the same issue and fixed it by simply adding FirebaseDynamicLinksCustomDomains key to Info.plist.
It is mentioned in the official document of Firebase: https://firebase.google.com/docs/dynamic-links/custom-domains#set_up_a_custom_domain_in_the
I think the value should be supplied as Array even when you have only one custom domain.
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://my.custom.domain.com/</string>
</array>
React Native: 0.59.5 React Native Firebase: 5.3.1 pod 'Firebase/DynamicLinks', '5.20.1'
Thanks for reporting what worked for you, @masako-yamada. I did already have the FirebaseDynamicLinksCustomDomains key with an array of custom domains that have been added to Firebase.
I do notice you are running a higher pod version of everything than I am. Looking at the Firebase iOS SDK release notes, I only find mention of when custom domains were added in 5.14.0 (December 2018), and no mention in this project's release notes of any fixes or changes regarding this issue in react-native-firebase:5.3.1. I'm only on react-native-firebase:5.2.3 myself as I seem to recall it being the last version that supported RN 0.57, as this is a formerly ejected Expo application that still utilizes Expokit in a few places. I may try to see if bumping versions resolves it without completely destroying functionality this afternoon.
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?
This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.
cc @Salakar on v6
I think on v5 you might have success with this PR #2051 - you can try it via patch-package pretty easily as it is a one-line change. I'd love to hear if it works
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?
This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.
I have the same issue. Works with Firebase's domain (myapp.page.link) but with a custom domain firebase.links().getInitialLink() and firebase.links().onLink are never called.
pod 'Firebase/DynamicLinks', '~> 6.3.0'
"react-native": "0.59.9",
@aslattery hi! Any news on it?
Hi ! I got the same issue
I've updated to the version 5.5.6 with pods at 6.3.0 and it's working fine now. "react-native": "0.59.9"
For us , it is working with the following configuration:
firebase dependency in package.json 5.5.6 [react-native-firebase : '^5.5.6'] pods 6.3.0 ['Firebase/Core', '6.3.0'] react-native": "0.59.0"
we’ve got the same issue on react native firebase 6.0.1 and the problem is seen only on release iOS builds. Help?)
This helped me to clarify!
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://my.custom.domain.com/</string>
</array>
If you are using a custom domain you have to add this to your info.plist. The docs are a little bit confusing, since it has /links/share as a path in there!