react-native-deep-linking
react-native-deep-linking copied to clipboard
this lib is not working with react-native version 0.63.3
no events are getting fire here is my code
` componentDidMount() {
// Google SignIn init
GoogleUtil.configureGoogleSignIn();
// Register schemes
DeepLinking.addScheme('recreative://');
// Deep linking
Linking.addEventListener('url', this.handleUrl);
var url = Linking.getInitialURL()
.then((url) => {
if (url) {
Linking.openURL(url);
}
})
.catch((err) => console.error('An error occurred', err));
DeepLinking.addRoute('/UserProfile/:id', ({ scheme, path, id }) => {
console.log('response for deeplinking');
// recreative://UserProfile
// this.setState({ response });
console.log('scheme checking', scheme); // `facebook://`
console.log('path checking', path); // `/profile/33138223345`
console.log('id checking', id); // `33138223345`
NavigationService.navigate('UserProfile');
});
// Twitter SignIn init
// TwitterUtil.init();
setTimeout(() => {
SplashScreen.hide();
}, 2000);
}
componentWillUnmount() {
// Deep linking unmounting
Linking.removeEventListener('url', this.handleUrl);
// network info change remove listener
NetworkInfo.removeNetworkInfoListener(
this.state.store.dispatch,
networkActions.networkInfoListener,
);
}
handleUrl = (url) => {
console.log('checking url', url);
Linking.canOpenURL(url).then((supported) => {
if (supported) {
DeepLinking.evaluateUrl(url);
}
});
};`
Have you already tried to add this code in your AppDelegate.m
(source: https://reactnative.dev/docs/linking#enabling-deep-links)?
// iOS 9.x or newer
#import <React/RCTLinkingManager.h>
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [RCTLinkingManager application:application openURL:url options:options];
}
instead of (the one documented in the current documentation)
// iOS 8.x or older
#import <React/RCTLinkingManager.h>
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [RCTLinkingManager application:application openURL:url
sourceApplication:sourceApplication annotation:annotation];
}
To go further, if you already have openUrl
implemented in AppDelegate.m
(for FBDSK for example), you can use (source: https://github.com/thebergamo/react-native-fbsdk-next/#32-ios)
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
return YES;
}
if ([RCTLinkingManager application:app openURL:url options:options]) {
return YES;
}
return NO;
}