AppDelegate.m文件中有两个包冲突

时间:2017-04-23 15:12:05

标签: ios objective-c react-native react-native-ios

我在项目中使用https://github.com/devfd/react-native-google-signinhttps://github.com/luisfcofv/react-native-deep-linking个包。我没有解决AppDelegate.m文件的以下部分,以便包可以工作。

对于这个本地反应 - 谷歌登录

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  return [RNGoogleSignin application:application openURL:url
                      sourceApplication:sourceApplication annotation:annotation];
}

对于这种反应原生深层链接

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  return [RCTLinkingManager application:application openURL:url
                      sourceApplication:sourceApplication annotation:annotation];
}

我不擅长Objective-C。如何使用单个函数返回RNGoogleSignin和RCTLinkingManager?

1 个答案:

答案 0 :(得分:5)

由于两种方法都返回BOOL,您可以尝试这样的方法:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
   BOOL success = [RNGoogleSignin application:application openURL:url
                      sourceApplication:sourceApplication annotation:annotation]) 
   if (!success)
       success = [RCTLinkingManager application:application openURL:url
                      sourceApplication:sourceApplication annotation:annotation];

   return success;
}

根据@rmaddy的评论进行了更新。