React native deep linking not working when app is in background state React native
Asked Answered
M

1

6

When the app is closed, I am able to get deep link url that is clicked by Linking.getInitialURL(). When the app is in the background state, then nothing is mounted. So, I am not able to get the url even by the Linking.addEventListener('url', method_name).

What is the way to achieve this?

Married answered 26/4, 2019 at 9:39 Comment(2)
its because componentDidMount() was already executed when u open your app while it's in a background.Annapolis
@Dalbir Kaur have you found the solution for this?Valenciavalenciennes
F
0

this is happening because Linking.addEventListener is not working and only Linking.getInitialURL is working

to make Linking.addEventListener work we need to code natively in iOS Appdelegate.m

if you are using FBSDK code this

- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *,id> *)options {
  //[RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation]
  
  return [RCTLinkingManager application:application openURL:url options:options] || [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url options:options] || [RNGoogleSignin application:application openURL:url options:options];

  return YES;
}
Fiery answered 18/2, 2021 at 13:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.