We have integrated rnfirebase dynamic links in our app and it usually works well. But sometimes we have a quirk, where dynamic links open the app, but don't trigger the listener.
I can usually reproduce it by following these instructions:
my app maximizes again correctly, but there is no dynamic link change or anything passed and so the app stays on the homescreen.
I tried to debug it, but couldn't find a way.
Here is my Podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'MyApp' do
rn_path = '../node_modules/react-native'
rn_maps_path = '../node_modules/react-native-maps'
pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
pod 'React', path: rn_path, subspecs: [
'Core',
'RCTActionSheet',
'RCTAnimation',
'RCTGeolocation',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket'
]
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Required by RNFirebase
pod 'Firebase/Coreβ, '~> 5.9.0'
# [OPTIONAL PODS] - comment out pods for firebase products you won't be using.
pod 'Firebase/DynamicLinks', '~> 5.9.0'
pod 'Firebase/Performance', '~> 5.9.0'
pod 'Firebase/Messaging', '~> 5.9.0'
pod 'Firebase/RemoteConfig', '~> 5.9.0'
pod 'Fabric'
pod 'Crashlytics'
# react native maps
pod 'react-native-maps', path: rn_maps_path
pod 'GoogleMaps' # Remove this line if you don't want to support Google Maps on iOS
pod 'react-native-google-maps', path: rn_maps_path # Remove this line if you don't want to support Google Maps on iOS
# linear gradient
pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
pod 'RNSVG', :path => '../node_modules/react-native-svg'
pod 'react-native-blur', :path => '../node_modules/react-native-blur'
pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'react-native-google-maps'
target.build_configurations.each do |config|
config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
end
end
if target.name == "React"
target.remove_from_project
end
# The following is needed to ensure the "archive" step works in XCode.
# It removes React & Yoga from the Pods project, as it is already included in the main project.
# Without this, you'd see errors when you archive like:
# "Multiple commands produce ... libReact.a"
# "Multiple commands produce ... libyoga.a"
targets_to_ignore = %w(React yoga)
if targets_to_ignore.include? target.name
target.remove_from_project
end
end
end
iOS
macOS Sierra
Xcode
React Native
version:0.54.1 - 0.57.0 (I've tried with multiple versions in between, but same result everywhere)
React Native Firebase
Version:4.3.0 - 5.0.0 (I've tried with different versions, but same result)
Firebase
Module:dynamic links
typescript
?no
Hello, same issue here,
I notice when I click the second time on the link the app open and navigate correctly.
In a simulator on the desktop this works fine and trigger the link all the times, but in a device don't.
In Android, I don't have any issue with this.
Edit --
After some more tests, I realize that the issue only happens in the new iOS 12.
Can you confirm @SimonErich ?
I have similar issue here, but it happened if the app has already opened on the background. Dynamic links only works if the app is not open prior to receiving the link on iOS, but Android works as expected. Anyone knows how to solve it?
Same here.
getInitialLink - works fine.
onLink - don't trigger, if the app has already opened.
I have same problem here!
I realize that it happened when app is running in background on iOS and I open Deeplink twice, always in the second moment firebase.links().onLink don't trigger
Same problem... no idea how to debug this. getInitialLink works every time, but onLink often doesn't get triggered correctly the first time I click a link. If it doesn't get triggered the first time, I will re-click the link and it gets triggered the second time. It only gets triggered every other time (2, 4, 6...). Happening on a real device using iOS version 12.0.
Any updates on this? I can't even get it to trigger on every other click. Trying on emulator and physical devices on iOS 12.0.
Did some exploring inside the FirebaseDynamicLinks pod and on line 63 of RNFirebaseLinks.m
is:
if (dynamicLink && dynamicLink.url && error == nil) {
For some reason, dynamicLink
is nil
, even though I'm using the "Link preview (debug)" option from the firebase console.
getInitialLink works just fine.
Yeah we still don't have a solution either and it's a really big problem for us right now.
Has anyone of you solved this problem?
@SimonErich I finally solved the problem today. Change this
[FIROptions defaultOptions].deepLinkURLScheme = @"https://xxxx.page.link"
to this:
[FIROptions defaultOptions].deepLinkURLScheme = @"com.example.app";
and make sure it's listed in XCode >> Info >> URL Types
Only other thing I can say is to upgrade to what they released today https://rnfirebase.io/docs/v5.x.x/release-notes#5.1.0
Thanks to this post
@jackcbrown89 thank you for coming back to share your solution.
Is that everything you did? And you are sure it's working now?
I updated react-native-firebase to 5.1.0 and also changed the url deepLinkingScheme + url types to my app identifier instead of the url, but I still have the same problem.
(in the dynamic link doc on rnfirebase it states, that you can either use your app identifier or any other unique value, so that shouldn't really make a difference as long as they are in sync. right?)
This is my AppDelegate.m file:
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>
#import "RNFirebaseLinks.h"
#import "RNSplashScreen.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIROptions defaultOptions].deepLinkURLScheme = @"com.myapp.app";
[FIRApp configure];
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"MyApp"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[RNSplashScreen show];
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<NSString *, id> *)options {
return [[RNFirebaseLinks instance] application:application openURL:url options:options];
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
{
return [[RNFirebaseLinks instance] application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}
@end
Under XCode -> Capabilities -> Associated domains I have:
applinks:nzh323.app.goo.gl
(we are still using the older URL scheme - could that be a problem ? although, I've also tried with a new one and same error)
And I've added a URL type with Identifier BundleID
and the url scheme com.myapp.app
@SimonErich Could you share your info.plist, entitlements file, and link details (from firebase console)? Also, the old scheme should be fine.
@jackcbrown89 thanks for sharing your solutions, for me doesn't work too.
Update to 5.1 and change [FIROptions defaultOptions].deepLinkURLScheme and the problem persist.
Thanks.
I just checked everything again and in my AppDelegate.m file I get the following warning from XCode:
Conflicting parameter types in implementation of
'application:continueUserActivity:restorationHandler:': 'void (^ _Nonnull __strong)
(NSArray<id<UIUserActivityRestoring>> * _Nullable __strong)' vs 'void (^__strong _Nonnull)(NSArray
* _Nullable __strong)'
Maybe this has something to do with the problem?
I've searched for this warning and found the issue #1592, which is tagged to be resolved in react-native-firebase 6.0.0.
Could that be part of the problem?
Here are the files:
info.plist: https://pastebin.com/bXBNaQNz
entitlements file: https://pastebin.com/tT6J1LNY
Hmmm this is weird.
I have tried to implement deep linking with react natives Linking module as described here:
https://facebook.github.io/react-native/docs/linking
But it seems like it has the same behavior.
Most of the time I get the link, but sometimes not.
I have only tried it using the firebase short links (xxx.app.goo.g/yyyy) and most of the time it worked, but sometimes the listener of Linking was not called.
For that reason I don't know whether it is a react-native, firebase or rnfirebase problem.
Can any of you confirm this behavior with react-natives Linking.
Or can any of you narrow it down a bit to find out where to dump the issue. (react-native project or here)
I think I have found the issue.
I was debugging the native RNfirebase code. Although I don't know objective C I have found that every second time the app is brought to foreground by link it fails right here with the following error: -[RNFirebaseLinks application:continueUserActivity:restorationHandler:]_block_invoke [Line 80] Failed to handle universal link: LINK error Error Domain=NSPOSIXErrorDomain Code=53 "Software caused connection abort" UserInfo={_kCFStreamErrorCodeKey=53, _kCFStreamErrorDomainKey=1}
(where the LINK is the actual link)
I have no idea how to solve this issue but maybe this info could help someone who knows how to solve it....
Anyone managed to solve this yet?
How did you deal with it? Are there any alternatives maybe?
@SimonErich could you share a gif of this happening with the same dynamic link?
I think @kaladivo has stumbled onto one of the causes, if you're on iOS 12 then it's most likely that that is the issue, it's a bug in iOS it seems and it's not just this lib that has the issue; see https://github.com/AFNetworking/AFNetworking/issues/4279
There are some suggestions on there on how to work around it / temporarily patch it (e.g. https://github.com/AFNetworking/AFNetworking/issues/4279#issuecomment-427830725). If anyone can get it working with one of those and send a PR over that'd be great π
Hello !
I have this bug too.
In the XCode console, i got this :
[RNFirebaseLinks application:continueUserActivity:restorationHandler:]_block_invoke [Line 67] Failed to handle universal link: my.page.link.url
my conf :
RN 0.57.8
react-native-firebase : 5.1.0-rc2
test on iphone 6s device.
How do you deal with it ?
Having exactly the same problem but only for iOS.
getInitialLink()
: Works fine on Android and iOS
onLink()
: Is not triggered for iOS if the application is already opened
Also same issue on iOS.
Although getInitialLink()
not working when installing the app from a specific link!
Have landed @benschell PR which should solve this issue. It'll be in the next release. Let me know if I can go ahead and close this.
This is amazing news. Thanks @Salakar . Any idea when the next release is due?
I'll publish 5.2.1 early next week with this in. Thanks
@Salakar Thanks, man :)
v5.2.1 is up. Thanks all π
Loving react-native-firebase
and the support we provide? Please consider supporting us with any of the below:
React Native Firebase
and Invertase
on Twitter We still seem to be experiencing this issue on 5.2.1
. I've upgraded pods too. I'm confused why the workaround didn't work for us. I don't have a very good way to share how to reproduce it as it's in a large app. Just wanted to see if anyone else is still having this issue.
Hey, 5.2.1 didn't help me on iOS 12. It works on initial url open, but not when app is already in the background.
Update: nope, seems to be fixed. My problem was that I subscribed to url event with RN's native Linking
function. I had to subscribe with firebase.links().onLink
instead
@OzzieOrca have you solved it? I'm still getting the same issue
I still have the same issue. When opening the link from browser, This works fine but when this link is inside another app I get the following error
-[RNFirebaseLinks application:continueUserActivity:restorationHandler:]_block_invoke [Line 83] Failed to handle universal link: asdf.page.link
Any solution for this?
@FrankGoortani did you solved it?
Have the same issue
I have found a workaround:
Open Libraries/RNFirebase.xcodeproject/RNFirebase/links/RNFirebaseLinks.m
in xCode
Make sure your code is upto date with this commit: https://github.com/invertase/react-native-firebase/pull/1841/commits/29d0061af2598892cd37becf231f6e929f8399d7
Now, edit the next line after [self sendJSEvent:self name:LINKS_LINK_RECEIVED body:url.absoluteString];
β mostly line# 66 or 71 β to look like following:
} else if (error != nil && (([NSPOSIXErrorDomain isEqualToString:error.domain] && error.code == 53) || [NSURLErrorDomain isEqualToString:error.domain])) {
The issue as per me is that most of the time in iOS while waking up from background firebase tries to resolve the URL too quick and iOS throws Returning ENOTCONN because protocol has not yet been set up
.
@Salakar check out that tidbit from @mehuleo - looks very interesting - does the reasoning appear sound to you? Maybe @mehuleo could propose a PR? @mehuleo - just to make sure - you saw errors before, and then after adding the extra boolean test for NSURLErrorDomain to trigger retry in that case, you see more success?
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 problem.When the app is running in background on iOS and I open the link twice or open 2 links one after the other, always the second moment firebase.links().onLink does not trigger. If I open a link and then open the second link after say 2-3 minutes, then it opens.
Same problem happening with me too. getInitialLink works every time, but onLink often doesn't get triggered correctly. It triggered the first time. In the second time it is not triggering. It only gets triggered every other time (1, 3, 5...). Happening on a real device using iOS version 13.3.1.
"react-native-firebase": "^5.6.0",
Can you try with 5.5.6 and tell me if you have the same problem ?
@IcebergRage Downgrading the version did the trick! Thanks a ton.
Hey @IcebergRage / @getumangon that's very interesting but not the intended effect. Can someone post a PR that fixes that regression and I can get another 5.x build out.
There are not many commits between v5.5.6 tag and tip of v5.x.x branch https://github.com/invertase/react-native-firebase/compare/v5.5.6...v5.x.x - it has to be in there somewhere and I'd welcome a PR
Honestly - going through that diff - all I see SDK update from 6.8.0 to 6.13.0. I wonder if you could use v5.6.0 with SDK 6.8.0 and it would work? Or if you updated all the way to 6.24.0 if it would work - in other words if this is/was just an upstream SDK issue in those versions. Note that the point of the v5.x.x maintenance is to allow use of modern SDKs so you should be able to compile and use iOS SDK 6.24.0 without problems (I do in my project)
I have the same issue on Android. I'm using dynamic links 6.7.1, getInitialLink() works very well, but onLink works only with a second time click.
Any suggestion?
Why is this issue closed? Seems like the problem isn't fixed.
I'm also experiencing this issue - here's my config:
"@react-native-firebase/app": "^8.2.0",
"@react-native-firebase/dynamic-links": "^7.4.2",
"react-native": "0.61.5",
When I launch the app from closed state, getInitialLink
gets consistently triggered. However when I launch from the background state, onLink
is inconsistently triggered. There doesn't seem to be a consistent pattern either, like every other time. I've only been able to successfully trigger onLink
up to 3 times in a row, so the issue is quite frequent.
Whenever onLink
fails to trigger, Xcode log shows the following error:
RNFBDynamicLinks: Unknown error occurred when attempting to handle a universal link: Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."
@jkim430 because it was opened almost 2 years ago? Open a new issue with full details. The amount of change in upstream SDKs and this module in 2 years is difficult to imagine
Most helpful comment
Same here.
getInitialLink - works fine.
onLink - don't trigger, if the app has already opened.