react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

🔥 [Dynamic Links][iOS] Unable to use custom domain with getInitialLink() or onLink()

Open awslattery opened this issue 7 years ago • 17 comments

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
  • Build Tools:
    • Xcode 10.1 (10B61), Android Studio 3.3.1
  • React Native version:
    • 0.57.1 (Expo 32 Fork)
  • React Native Firebase library version:
    • 5.2.3
  • Firebase module(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

awslattery avatar Mar 26 '19 00:03 awslattery

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

romit07 avatar Mar 27 '19 14:03 romit07

   [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.

awslattery avatar Mar 27 '19 19:03 awslattery

We are having the same issue. Works with default example.page.link but not with custom dynamic links

ghost avatar Apr 09 '19 13:04 ghost

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'

masako-yamada avatar May 08 '19 16:05 masako-yamada

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.

awslattery avatar May 08 '19 17:05 awslattery

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.

stale[bot] avatar Jun 05 '19 17:06 stale[bot]

cc @Salakar on v6

Ehesp avatar Jun 06 '19 09:06 Ehesp

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

mikehardy avatar Jun 07 '19 19:06 mikehardy

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.

stale[bot] avatar Jul 05 '19 20:07 stale[bot]

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.

stale[bot] avatar Jul 20 '19 21:07 stale[bot]

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",

robertvorthman avatar Jul 23 '19 17:07 robertvorthman

@aslattery hi! Any news on it?

LevanKvirkvelia avatar Aug 14 '19 15:08 LevanKvirkvelia

Hi ! I got the same issue

parwan-as avatar Sep 04 '19 09:09 parwan-as

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"

fxhrgco avatar Sep 24 '19 13:09 fxhrgco

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"

VikasSahu avatar Nov 16 '19 09:11 VikasSahu

we’ve got the same issue on react native firebase 6.0.1 and the problem is seen only on release iOS builds. Help?)

Andriiklymiuk avatar Nov 30 '19 17:11 Andriiklymiuk

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!

festapp86 avatar Jan 19 '21 19:01 festapp86