duplicate declaration RCTLinking Manager and ShareMenuManager
I get an error saying 'duplicate declaration of method application'. I had already added a method with the name for deep linking for RCTLinkingManager. what can I do to solve this issue such that I can use both. Sorry if this is a noob question I have zero experience in Swift
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [RCTLinkingManager application:application openURL:url options:options];
}
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [ShareMenuManager application:app openURL:url options:options];
}
Same issue
For my case, I solved it like this. Just merged the two application methods and added a check for the url argument. However, I only needed to look out for the prefix of the openURL argument. You might want to change the urlString check so that it recognises your custom deep links.
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
// Check if the passed url is a <YOUR_URL_SCHEME_NAME>://- or a Spotify-url
NSString *urlString = url.absoluteString;
// If it contains <YOUR_URL_SCHEME_NAME>:// handle it with the ShareMenuManager
if ([urlString hasPrefix:@"<YOUR_URL_SCHEME_NAME>://"]) {
NSLog(@"Entered with the following string: %@s", urlString);
return [ShareMenuManager application:application openURL:url options:options];
}
// Else, go into react-native-spotify-remote
return [[RNSpotifyRemoteAuth sharedInstance] application:application openURL:url options:options];
}
Hope this helps although it's not the entire solution to your problem.
doesn't the share extension use the same url scheme?
Can anyone provide a snippet merging RCTLinkingManager and ShareMenuManager in the openURL method?
I'd bet >90% of react-native-share-menu already use react-navigation with deep links, so are confronted with this issue. This is more of a request for documentation than an issue per se
@shawarmaz not sure if you got this yet or not, but here's the solution I used...
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
// check url string
NSString *urlString = url.absoluteString;
// if url contains ShareExtension prefix, handle with ShareMenuManager
if ([urlString hasPrefix:@"<YOUR_URL_SCHEME_NAME>://"]) {
NSLog(@"Entered with the following string: %@s", urlString);
return [ShareMenuManager application:application openURL:url options:options];
}
// else use React Native Linking
return [RCTLinkingManager application:application openURL:url options:options];
}