I have my android app (react-native based) and the deep link first time when I run it while the app is not running in the background works great, but when the app runs in the background and i click on the deep-link it doesn't even open the app ... I'm not sure even where to start with this bug I tried a few console.logs
in lifecycle events but they don't even run.
please guide me where should I look for the issue and how to fix it, thanks!
The deep linking is working as expected for me even the app is in background
. Please check the below specifications.
Node Version : v12.18.x OR Greater NPM Version : v6.14.x OR Greater react-native-cli : 2.0.1 react-native : 0.63.x OR Greater
Please check if you have added below line in your AppDelegate.m
.
#import <React/RCTLinkingManager.h>
It must be added above #ifdef FB_SONARKIT_ENABLED
line. Adding it below this line will cause failing of build while Archiving it for release.
Please check if you have added below code in your AppDelegate.m
which is responsible for deep linking.
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { return [RCTLinkingManager application:application openURL:url options:options]; }
It will work for app cold boot, but it will not work if your app is in background
. For this, you need to add below code in your AppDelegate.m
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id> *_Nullable))restorationHandler { return [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; }
This should work irrespective of your AppState: active **OR** background
.
This worked for me as expected! Give it a try. This is should definitely work.
Thanks in advance!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With