react-native-firebase
react-native-firebase copied to clipboard
π₯ dynamicLinks().onLink not being called on iOS
Issue
onLink not working on iOS.
dynamicLinks().onLink is not getting called on iOS. When I click a dynamic link, the app is being opened, but the callback is not being called for some reason.
We noticed this when we upgraded all firebase libraries. The latest one where this callback is working is 12.8.0, so I assume something changed in 12.9.0 that broke this.
We didn't change anything in our configuration, we just upgraded the libraries.
It looks like the problem is that the link is not being parsed correctly (not sure why).
dynamicLinks().resolveLink throws this error: INFO [Error: [dynamicLinks/not-found] Dynamic link not found].
I'm not sure what changed in 12.9.0. Maybe we should change something or maybe we're missing some configuration that's required after 12.8.0?
Project Files
Javascript
Click To Expand
package.json:
{
"name": "app",
"version": "2.7.0",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"postinstall": "patch-package"
},
"dependencies": {
"@amplitude/react-native": "2.3.3",
"@feathersjs/authentication-client": "4.5.11",
"@feathersjs/feathers": "4.5.11",
"@feathersjs/socketio-client": "4.5.11",
"@react-native-async-storage/async-storage": "1.14.1",
"@react-native-clipboard/clipboard": "^1.9.0",
"@react-native-community/datetimepicker": "3.0.3",
"@react-native-community/masked-view": "0.1.10",
"@react-native-firebase/analytics": "14.1.0",
"@react-native-firebase/app": "14.1.0",
"@react-native-firebase/dynamic-links": "14.1.0",
"@react-navigation/bottom-tabs": "6.0.4",
"@react-navigation/native": "6.0.2",
"@react-navigation/native-stack": "^6.0.5",
"@sentry/react-native": "3.2.3",
"@types/debounce": "1.2.0",
"@types/react-native-actionsheet": "2.4.2",
"@types/react-native-video": "5.0.3",
"@types/react-redux": "7.1.9",
"@types/yup": "0.29.11",
"countries-and-timezones": "^3.3.0",
"date-fns": "2.16.1",
"debounce": "1.2.0",
"formik": "2.1.5",
"javascript-time-ago": "^2.3.8",
"just-group-by": "^2.0.1",
"moment": "2.29.1",
"patch-package": "^6.4.7",
"postinstall-postinstall": "^2.1.0",
"query-string": "7.0.1",
"react": "17.0.2",
"react-native": "0.66.4",
"react-native-actionsheet": "2.4.2",
"react-native-agora": "3.5.0",
"react-native-bootsplash": "3.1.2",
"react-native-config": "1.3.3",
"react-native-device-info": "8.0.0",
"react-native-draggable": "^3.3.0",
"react-native-flash-message": "0.1.16",
"react-native-formik": "1.7.8",
"react-native-gesture-handler": "1.10.3",
"react-native-gifted-chat": "0.16.3",
"react-native-iap": "5.2.6",
"react-native-image-crop-picker": "0.35.1",
"react-native-keep-awake": "4.0.0",
"react-native-keyboard-aware-scroll-view": "0.9.5",
"react-native-localize": "^2.1.6",
"react-native-modal-datetime-picker": "9.0.0",
"react-native-modalize": "2.0.8",
"react-native-onesignal": "4.3.3",
"react-native-orientation-locker": "https://github.com/wonday/react-native-orientation-locker#master",
"react-native-pager-view": "^6.0.0-rc.0",
"react-native-parsed-text": "0.0.22",
"react-native-portalize": "1.0.7",
"react-native-reanimated": "1.13.0",
"react-native-safe-area-context": "3.1.7",
"react-native-screens": "3.5.0",
"react-native-share": "5.1.7",
"react-native-svg": "12.1.0",
"react-native-svg-transformer": "0.14.3",
"react-native-video": "5.1.0-alpha8",
"react-native-video-controls": "2.7.1",
"react-redux": "7.2.1",
"redux": "4.0.5",
"redux-persist": "6.0.0",
"rn-placeholder": "3.0.3",
"socket.io-client": "2.3.0",
"url-pattern": "1.0.3",
"yup": "0.29.3"
},
"devDependencies": {
"@babel/core": "7.12.9",
"@babel/runtime": "7.12.5",
"@react-native-community/eslint-config": "2.0.0",
"@testing-library/jest-native": "4.0.1",
"@testing-library/react-hooks": "^5.1.1",
"@testing-library/react-native": "7.2.0",
"@types/jest": "26.0.2",
"@types/react-native": "0.64.4",
"@types/react-native-keep-awake": "2.0.3",
"@types/react-test-renderer": "17.0.1",
"@typescript-eslint/eslint-plugin": "2.34.0",
"@typescript-eslint/parser": "2.34.0",
"babel-jest": "26.6.3",
"eslint": "7.14.0",
"eslint-config-airbnb": "18.2.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-jsx-a11y": "6.3.1",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-react": "7.20.6",
"eslint-plugin-react-hooks": "4.2.0",
"jest": "26.6.3",
"metro-react-native-babel-preset": "0.66.2",
"prettier": "2.1.2",
"react-test-renderer": "17.0.2",
"typescript": "4.3.5"
},
"jest": {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"setupFilesAfterEnv": [
"./jest.setup.ts",
"@testing-library/jest-native/extend-expect"
],
"transformIgnorePatterns": [
"node_modules/(?!static-container)/"
]
}
}
firebase.json for react-native-firebase v6:
{
"hosting": {
"appAssociation": "AUTO",
"rewrites": [ { "source": "/**", "dynamicLinks": true } ]
}
}
iOS
Click To Expand
ios/Podfile:
- [ ] I'm not using Pods
- [x] I'm using Pods and my Podfile looks like:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
target 'App' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
pod 'react-native-config', :path => '../node_modules/react-native-config'
pod 'react-native-onesignal', :path => '../node_modules/react-native-onesignal'
pod 'react-native-keep-awake', :path => '../node_modules/react-native-keep-awake'
pod 'react-native-video', :path => '../node_modules/react-native-video'
target 'AppTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
target 'OneSignalNotificationServiceExtension' do
pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
end
AppDelegate.m:
#import <Firebase.h>
#import "AppDelegate.h"
#import "RNBootSplash.h"
#import "Orientation.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#ifdef FB_SONARKIT_ENABLED
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
static void InitializeFlipper(UIApplication *application) {
FlipperClient *client = [FlipperClient sharedClient];
SKDescriptorMapper *layoutDescriptorMapper =
[[SKDescriptorMapper alloc] initWithDefaults];
[client addPlugin:[[FlipperKitLayoutPlugin alloc]
initWithRootNode:application
withDescriptorMapper:layoutDescriptorMapper]];
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
[client addPlugin:[FlipperKitReactPlugin new]];
[client addPlugin:[[FlipperKitNetworkPlugin alloc]
initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
[client start];
}
#endif
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Firebase Config
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
#ifdef FB_SONARKIT_ENABLED
InitializeFlipper(application);
#endif
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self
launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"Livelix"
initialProperties:nil];
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];
return YES;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#ifdef FB_SONARKIT_ENABLED
return
[[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"
fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main"
withExtension:@"jsbundle"];
#endif
}
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [Orientation getOrientation];
}
@end
Android
Click To Expand
Have you converted to AndroidX?
- [ ] my application is an AndroidX application?
- [ ] I am using
android/gradle.settingsjetifier=truefor Android compatibility? - [ ] I am using the NPM package
jetifierfor react-native compatibility?
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
Click To Expand
react-native info output:
System:
OS: macOS 12.0.1
CPU: (8) x64 Apple M1
Memory: 31.80 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.17.4 - /usr/local/bin/node
Yarn: 1.22.11 - /opt/homebrew/bin/yarn
npm: 7.24.1 - /opt/homebrew/bin/npm
Watchman: 2021.06.07.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
Android SDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7935034
Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
Languages:
Java: 11.0.10 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.66.4 => 0.66.4
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
- 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
react-native-firebaseversion you're using that has this issue:14.1.0
Firebasemodule(s) you're using that has the issue:react-native-firebase/dynamic-links
- Are you using
TypeScript?- Yes,
4.3.5
- Yes,
- π Check out
React Native FirebaseandInvertaseon Twitter for updates on the library.
Happens to me as well.
Also here, but I am using version 14.2.2. I feel like downgrading to 12.8.0 is not good way to go for me.
Any other ideas why onLink never triggers? My app opens, when I click on link, but onLink never triggers if app is active in background.
I have added FirebaseDynamicLinksCustomDomains in info.plist ... so it shouldn't be that.
EDIT: I noticed that is working with Linking package from react-native:
Linking.addEventListener("url", (link) => {
console.log("GOT LINK", link);
});
Linking.getInitialURL().then((link) => {
console.log("INITIAL LINK", link);
});
I wonder, is it the same thing, Is it compatible with firebase dynamic links?
I don't know why but I have also heard many users just use the react-native Linking built-in from react-native with success as a workaround
Same here I get the dynamic link from the react native built in Linking. The problem with this is it doesn't work on app install. So the big promise of dynamic link doesn't work
Ah yes, I forgot that the install link case is affected by that. What happens, incidentally, if you add a delay before calling getInitialLink? I'm not sure if it's this thread or a different one but if I remember correctly there was some indication that a delay made a difference. Just a workaround, but it would be an interesting and quick test
Looks like this is an issue for both iOS and Android.
I have the same problem. I just installed version 14.2.2 and couldn't get it to work. Tutorials are not working anymore.
any news on this? It seems that I'm currently facing this issue on my app.
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 it does still require the community's attention
@mikehardy @Salakar @Ehesp Experiencing the same issue hereβ¦
It looks (based on what I read around) that it might be caused by an "ordering" issue in applinks: entitlement? The problem is I have no control over it as I'm using expo development build with easβ¦
On Android, everything works as expected for me (I was surprised, that's generally the opposite !)
but on IOS I always get null with const initialLink = await dynamicLinks().getInitialLink(); and same with the listener dynamicLinks().onLink.
The issue is we cannot rely on Linking.getInitialURL() NOR its listener because it resolves to the short link URL and not the deeplink URL. While for most people those are the same link, it's not always the case + the install link is affected too.

See "Deeplink" is not the same as "short link". On android, we get the good one because it works.
I'm on EXPO SDK44 with Dynamic link 14.9.1
have in app.json
FirebaseDynamicLinksCustomDomains: ["https://links.stride-power.com"], also associatedDomains: ["applinks:links.stride-power.com"],
A Hacky solution (that remains free)
The unique hacky solution is to avoid using react native firebase SDK and handles links with classic Linking API. Fully using JavaScript Then define the dynamic link as follow (in the console or using code):
- The Β« Short URL Β» becomes the URL that opens the app universal link (the one that start the app). For that you need to declare
intentFiltersandAASA(if you're using expo : https://docs.expo.dev/guides/linking/#universaldeep-links-without-a-custom-scheme) otherwise handle the job with the equivalent code on bare workflow. - Deeplink URL (Step 2 when using web console) becomes just web fallback URL. It will be opened if the Universal link of the Short URL isn't handled and if there user was not redirected to the store. Which means, most of the time the user has the app but has an old device that doesn't play with Universal Links.
- Maybe on the web fallback page, you can use some hacky javascript that tries to open the app using a scheme like
stride://somedeeplink, this can be some parameter from the step 2 URL. But it might not be used because the user will probably end up on the store page instead.
Short answer: Remove react native firebase dynamic link and just use firebase as apple-app-site-association free hosting service and free redirect service if the app is not installed. But I'm not sure about installing links after all of this. Maybe they might work if you set Deeplink URL exactly the same as Shortlink URL (or some different URL host that you add in prefixes key in react-navigation Linking config, but with exact same path)
Another solution (which might not remains free)
Leave firebase for branch.io or or appsflyer π
Have you seen the dynamicLinks().resolveLink method? I implemented that to handle this and a similar case - I use that for camera capture of QR codes that have the short link embedded, to resolve them. So you can take the result of any Linking native-component API that might be short or long and run it through there to see if it's a deep link, I do that for initial links and ongoing links, and I know enough about my links post-resolution that I can reliably behave according to my use cases ?
We were having this issue as well... I did some digging and it seems to be because we had:
<key>FirebaseAppDelegateProxyEnabled</key>
<false />
Set in our info.plist file. This disables the method swizzling which seems to be required by the code in react native firebase here: https://github.com/invertase/react-native-firebase/blob/v14.9.3/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksAppDelegateInterceptor.m#L32 to hook into the openURL and restorationHandler methods in the AppDelegate.mm file...
To fix the issues we were having we removed those two lines from the Info.plist. Re-enabling method swizzling, and thereby allowing firebase react native to hook into the correct lifecycle functions in the app delegate.
I wonder if this is also what others are seeing? π Both dynamicLinks().onLink() and dynamicLinks().getInitialLink() seem to be working now! π (at least in development, haven't tested the fresh install case from the app store yet...)
@Shervanator So we need to set it to true ?
@Shervanator So we need to set it to true ?
For us we just had to remove it because we had set it years ago and no longer needed it
Hi All
I'm meeting with a weird bug, can anyone help me with this - In IOS, when you share a class via FB messenger and when a user clicks on the link - First time, it will take you to App Store saying the app is no longer available. Second time, it will take you to the Home screen of the App (not to the class). I've checked the logs, the link which we're sending is fine but the link which is taking the user back to the app is coming as NULL. And this particular thing is happening only in IOS FB messenger.
@imNKsid you may want to surf over to firebase-ios-sdk and see if they have open issues / open an issue there, taking care to include all relevant information to reproduce https://stackoverflow.com/help/how-to-ask
@mikehardy You have no issues at all with the dynamic links in any of your apps ?
Everything gets called on first launch and during runtime ? With proper values ?
I haven't tested it in a while, but in the past I was able to access the initial / app open dynamic links through a hybrid strategy of the dynamic links API here and https://reactnative.dev/docs/linking#getinitialurl
I do the same with the linking events for non-initial links, listen to built-in and react-native-firebase and resolveLink.
I'm not sure which API (react-native-firebase or Linking built-in) was the actual source, I found it to be a little finicky yes - some of the process like the applinks for custom schemes require careful configuration and async processes from apple/google post-install on a device - so I listen to all methods, pass results through the resolveLink method I implemented here, and after that in my testing at least it passed. This was all implemented a bit more than a year ago though, so my results may not be current. Testing them is a very time-consuming task for me and I've had other priorities
i'm still facing the same issues too
@mikehardy Were you able to get the initialUrl after an app install? Say a user is deep linked to the app store, and installs the app. The user opens the app, the deep link should be set as the initialURL. Are you able to get that link, or do you have any information on how it should work? Is firebase telling the app to set the initialURL, or does it come from the app store/google play?
Bump, any news here?
Sorry, no news and I'm out traveling right now so won't have time for quite a while. If this is something really important for you, you'll have to perform some investigation in my absence as it will take some time even after I'm back (mid August) before I've caught up on emergency-type stuff and can begin investigations like this
We were having this issue as well... I did some digging and it seems to be because we had:
<key>FirebaseAppDelegateProxyEnabled</key> <false />Set in our info.plist file. This disables the method swizzling which seems to be required by the code in react native firebase here: https://github.com/invertase/react-native-firebase/blob/v14.9.3/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksAppDelegateInterceptor.m#L32 to hook into the
openURLandrestorationHandlermethods in the AppDelegate.mm file...To fix the issues we were having we removed those two lines from the Info.plist. Re-enabling method swizzling, and thereby allowing firebase react native to hook into the correct lifecycle functions in the app delegate.
I wonder if this is also what others are seeing? π Both
dynamicLinks().onLink()anddynamicLinks().getInitialLink()seem to be working now! π (at least in development, haven't tested the fresh install case from the app store yet...)
I can confirm that removing method swizzling seems to solve this problem in my project
Why that's so hard. I have managed expo and firebase-react-native. Non of the methods of dynamicLinks() 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 attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
We were having this issue as well... I did some digging and it seems to be because we had:
<key>FirebaseAppDelegateProxyEnabled</key> <false />Set in our info.plist file. This disables the method swizzling which seems to be required by the code in react native firebase here: https://github.com/invertase/react-native-firebase/blob/v14.9.3/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksAppDelegateInterceptor.m#L32 to hook into the
openURLandrestorationHandlermethods in the AppDelegate.mm file... To fix the issues we were having we removed those two lines from the Info.plist. Re-enabling method swizzling, and thereby allowing firebase react native to hook into the correct lifecycle functions in the app delegate. I wonder if this is also what others are seeing? π BothdynamicLinks().onLink()anddynamicLinks().getInitialLink()seem to be working now! π (at least in development, haven't tested the fresh install case from the app store yet...)I can confirm that removing method swizzling seems to solve this problem in my project
I am facing this issue as well using. Seeing the reply above, I am wondering if using Expo (bare workflow in my case) might not interfere.
I can successfully work around this issue by using React Native Linking API.
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 attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.