r/reactnative • • May 17 '20

Objective C code - Duplicate Declaration Issue

Error: Duplicate declaration of method 'application:openURL:options:'

inFile: AppDelegate.m

I am working on an app using React-Native. That has react-native twitter Sign in and also Firebase Dynamic Links. I have no idea how objective C code works and would appreciate someone helping me out with the issue I am facing.

//Twitter Auth

- (BOOL)application:(UIApplication )app openURL:(NSURL )url options:(NSDictionary<NSString ,id> )options {

return [[Twitter sharedInstance] application:app openURL:url options:options];

// [RCTLinkingManager application:app openURL:url options:options];

}

//Dynamic Linking - React Navigation

- (BOOL)application:(UIApplication *)application

openURL:(NSURL *)url

options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options

{

return [RCTLinkingManager application:application openURL:url options:options];

}

Error: Duplicate declaration of method 'application:openURL:options:'

Thanking You!

4 Upvotes

7 comments sorted by

View all comments

Show parent comment

2

u/nokeeo May 17 '20
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)URL options:(NSDictionary<NSString ,id> *)options {
  if([RCTLinkingManager application:application openURL:URL options:options]) {
    return YES;
  } else if([[Twitter sharedInstance] application:app openURL:URL options:options]) {
    return YES;
  }
  return NO;
}

1

u/Dharmink May 18 '20

This is exactly what i was looking for i searched on Google with something like multiline return statement but couldn't really understand what was going on. Thank you so much!!